Exemple #1
0
static HB_ERRCODE pgsqlConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
{
   PGconn *       pConn;
   ConnStatusType status;
   const char *   pszHost;

   pszHost = hb_arrayGetCPtr( pItem, 2 );
   if( pszHost && ( strncmp( pszHost, "postgresql://", 13 ) == 0 || strchr( pszHost, '=' ) ) )
      pConn = PQconnectdb( pszHost );
   else
      pConn = PQsetdbLogin( pszHost, hb_arrayGetCPtr( pItem, 6 ), hb_arrayGetCPtr( pItem, 7 ), hb_arrayGetCPtr( pItem, 8 ), hb_arrayGetCPtr( pItem, 5 ), hb_arrayGetCPtr( pItem, 3 ), hb_arrayGetCPtr( pItem, 4 ) );

   if( ! pConn )   /* Low memory, etc */
   {
      /* TODO: error */
      return HB_FAILURE;
   }
   status = PQstatus( pConn );
   if( status != CONNECTION_OK )
   {
      /* TODO: error */
      PQfinish( pConn );
      return HB_FAILURE;
   }
   pConnection->pSDDConn = hb_xgrab( sizeof( SDDCONN ) );
   ( ( SDDCONN * ) pConnection->pSDDConn )->pConn = pConn;
   return HB_SUCCESS;
}
Exemple #2
0
static void hb_gaugeUpdate( PHB_ITEM pArray, float fPercent )
{
   int iCenter = ( ( hb_arrayGetNL( pArray, B_RIGHT ) - hb_arrayGetNL( pArray, B_LEFT ) ) / 2 ) + 1;
   int iRatio = hb_arrayGetNL( pArray, B_RIGHT ) - hb_arrayGetNL( pArray, B_LEFT ) - 1;
   int iRow;
   int iCols;
   int iMax;
   char szOldColor[ CLR_STRLEN ];
   char * szStr = "        ";
   char szPct[ 5 ];

   hb_gtGetColorStr( szOldColor );
   hb_gtSetColorStr( hb_arrayGetCPtr( pArray, B_BARCOLOR ) );

   fPercent = ( fPercent < 0 ? 0 : ( fPercent > 1 ? 1 : fPercent ) );
   iCols    = (int) (fPercent * iRatio);

   if( hb_arrayGetL( pArray, B_DISPLAYNUM ) )
   {
//    hb_snprintf( szPct, sizeof( szPct ), "%3.0f\%", fPercent * 100 );
      hb_snprintf( szPct, sizeof( szPct ), "%3.0f%%", fPercent * 100 );
      hb_gtWriteAt( (USHORT) hb_arrayGetNL( pArray, B_TOP ),
                    (USHORT) iCenter + 2, (BYTE *) szPct, 4 );
   }

   hb_gtBox( (SHORT) hb_arrayGetNL( pArray, B_TOP ) + 1, (SHORT) hb_arrayGetNL( pArray, B_LEFT ) + 1,
             (SHORT) hb_arrayGetNL( pArray, B_BOTTOM ) - 1, (SHORT) hb_arrayGetNL( pArray, B_RIGHT ) - 1,
             ( BYTE * ) szStr );

   iMax = hb_arrayGetNL( pArray, B_BOTTOM ) - hb_arrayGetNL( pArray, B_TOP ) - 1;
   for( iRow = 1; iRow <= iMax; iRow++ )
   {
      hb_gtRepChar( ( USHORT ) (iRow + hb_arrayGetNL( pArray, B_TOP )),
                    ( USHORT ) (hb_arrayGetNL( pArray, B_LEFT ) + 1),
                    ( BYTE ) * hb_arrayGetCPtr( pArray, B_BARCHAR ), ( USHORT ) iCols );
   }

   hb_gtSetColorStr( szOldColor );
}
Exemple #3
0
static int hb_gt_gui_optionPos( int id, int iType, PHB_ITEM pOptions )
{
   int iButton = 0;

   switch( id )
   {
      case IDOK:
         iButton = 0x0001;
         break;
      case IDCANCEL:
         iButton = 0x0002;
         break;
      case IDABORT:
         iButton = 0x0002;
         break;
      case IDRETRY:
         iButton = 0x0004;
         break;
      case IDIGNORE:
         iButton = 0x0008;
         break;
      case IDYES:
         iButton = 0x0010;
         break;
      case IDNO:
         iButton = 0x0020;
         break;
#ifdef IDTRYAGAIN
      case IDTRYAGAIN:
         iButton = 0x0004;
         break;
#endif
#ifdef IDCONTINUE
      case IDCONTINUE:
         iButton = 0x0008;
         break;
#endif
   }
   if( iButton )
   {
      int iOptions = ( int ) hb_arrayLen( pOptions ), i;

      for( i = 1; i <= iOptions; ++i )
      {
         id = hb_gt_gui_optionId( hb_arrayGetCPtr( pOptions, i ) );
         if( iButton == id || ( iOptions == 1 && iType == id ) )
            return i;
      }
   }
   return 0;
}
Exemple #4
0
/* --- SDD METHODS --- */
static HB_ERRCODE mysqlConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
{
   MYSQL *  pMySql;
   PHB_ITEM pItemUnixSocket = hb_arrayGetItemPtr( pItem, 7 );

   pMySql = mysql_init( NULL );
   if( ! mysql_real_connect( pMySql,
                             hb_arrayGetCPtr( pItem, 2 ) /* host */,
                             hb_arrayGetCPtr( pItem, 3 ) /* user */,
                             hb_arrayGetCPtr( pItem, 4 ) /* password */,
                             hb_arrayGetCPtr( pItem, 5 ) /* db */,
                             hb_arrayGetNI( pItem, 6 ) /* port */,
                             pItemUnixSocket && HB_IS_STRING( pItemUnixSocket ) ? hb_itemGetCPtr( pItemUnixSocket ) : NULL,
                             hb_arrayGetNI( pItem, 8 ) /* flags*/ ) )
   {
      hb_rddsqlSetError( mysql_errno( pMySql ), mysql_error( pMySql ), NULL, NULL, 0 );
      mysql_close( pMySql );
      return HB_FAILURE;
   }
   pConnection->pSDDConn = hb_xgrab( sizeof( SDDCONN ) );
   ( ( SDDCONN * ) pConnection->pSDDConn )->pMySql = pMySql;
   return HB_SUCCESS;
}
Exemple #5
0
static HB_ERRCODE pgsqlConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
{
   PGconn *       pConn;
   ConnStatusType status;

   pConn = PQsetdbLogin( hb_arrayGetCPtr( pItem, 2 ), NULL, NULL, NULL, hb_arrayGetCPtr( pItem, 5 ), hb_arrayGetCPtr( pItem, 3 ), hb_arrayGetCPtr( pItem, 4 ) );

   if( ! pConn )   /* Low memory, etc */
   {
      /* TODO: error */
      return HB_FAILURE;
   }
   status = PQstatus( pConn );
   if( status != CONNECTION_OK )
   {
      /* TODO: error */
      PQfinish( pConn );
      return HB_FAILURE;
   }
   pConnection->pSDDConn = hb_xgrab( sizeof( SDDCONN ) );
   ( ( SDDCONN * ) pConnection->pSDDConn )->pConn = pConn;
   return HB_SUCCESS;
}
Exemple #6
0
static const char * hb_dbTransFieldPos( PHB_ITEM pFields, HB_USHORT uiField )
{
   const char * szField = NULL;
   PHB_ITEM pItem;

   pItem = hb_arrayGetItemPtr( pFields, uiField );
   if( pItem )
   {
      if( HB_IS_ARRAY( pItem ) )
         szField = hb_arrayGetCPtr( pItem, DBS_NAME );
      else
         szField = hb_itemGetCPtr( pItem );

      if( *szField == '\0' )
         szField = NULL;
   }

   return szField;
}
Exemple #7
0
PHB_ITEM hb_libLoad( PHB_ITEM pLibName, PHB_ITEM pArgs )
{
   void * hDynLib = NULL;

   if( hb_itemGetCLen( pLibName ) > 0 )
   {
      int argc = pArgs ? ( int ) hb_arrayLen( pArgs ) : 0, i;
      const char ** argv = NULL;

      if( argc > 0 )
      {
         argv = ( const char ** ) hb_xgrab( sizeof( char * ) * argc );
         for( i = 0; i < argc; ++i )
            argv[ i ] = hb_arrayGetCPtr( pArgs, i + 1 );
      }

      if( hb_vmLockModuleSymbols() )
      {
         /* use stack address as first level marker */
         hb_vmBeginSymbolGroup( ( void * ) hb_stackId(), HB_TRUE );
#if defined( HB_OS_WIN )
         {
            void * hFileName;

            hDynLib = ( void * ) LoadLibraryEx( HB_ITEMGETSTR( pLibName, &hFileName, NULL ), NULL, LOAD_WITH_ALTERED_SEARCH_PATH );

            hb_strfree( hFileName );
         }
#elif defined( HB_OS_OS2 )
         {
            HB_UCHAR LoadError[ 256 ] = "";  /* Area for load failure information */
            HMODULE hDynModule;
            if( DosLoadModule( ( PSZ ) LoadError, sizeof( LoadError ),
                               ( PCSZ ) hb_itemGetCPtr( pLibName ), &hDynModule ) == NO_ERROR )
               hDynLib = ( void * ) hDynModule;
         }
#elif defined( HB_HAS_DLFCN )
         hDynLib = ( void * ) dlopen( hb_itemGetCPtr( pLibName ), RTLD_LAZY | RTLD_GLOBAL );

         if( ! hDynLib )
         {
            HB_TRACE( HB_TR_DEBUG, ( "hb_libLoad(): dlopen(): %s", dlerror() ) );
         }
#elif defined( HB_CAUSEWAY_DLL )
         hDynLib = LoadLibrary( hb_itemGetCPtr( pLibName ) );
#else
         {
            int iTODO;
         }
#endif
         /* set real marker */
         hb_vmInitSymbolGroup( hDynLib, argc, argv );

         hb_vmUnlockModuleSymbols();
      }

      if( argv )
         hb_xfree( ( void * ) argv );
   }

   if( hDynLib )
   {
      void ** pLibPtr = ( void ** ) hb_gcAllocate( sizeof( void * ), &s_gcDynlibFuncs );
      *pLibPtr = hDynLib;
      return hb_itemPutPtrGC( NULL, pLibPtr );
   }

   return NULL;
}
Exemple #8
0
const char * hb_errGetSubSystem( PHB_ITEM pError )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_errGetSubSytem(%p)", pError ) );

   return hb_arrayGetCPtr( pError, HB_TERROR_SUBSYSTEM );
}
Exemple #9
0
const char * hb_errGetOperation( PHB_ITEM pError )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_errGetOperation(%p)", pError ) );

   return hb_arrayGetCPtr( pError, HB_TERROR_OPERATION );
}
Exemple #10
0
const char * hb_errGetFileName( PHB_ITEM pError )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_errGetFileName(%p)", pError ) );

   return hb_arrayGetCPtr( pError, HB_TERROR_FILENAME );
}
Exemple #11
0
const char * hb_errGetDescription( PHB_ITEM pError )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_errGetDescription(%p)", pError ) );

   return hb_arrayGetCPtr( pError, HB_TERROR_DESCRIPTION );
}
Exemple #12
0
static PHB_EOL_INFO hb_mlGetEOLs( int iParam, int * piEOLs )
{
   PHB_EOL_INFO pEOLs = NULL;
   int iEOLs = 0;

#ifdef HB_EXTENSION
   char * szEOL;
   ULONG ulLen, ul;

   szEOL = hb_parc( iParam );
   if( szEOL )
   {
      ulLen = hb_parclen( iParam );
      if( ulLen )
      {
         pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) );
         pEOLs->szEOL = szEOL;
         pEOLs->ulLen = ulLen;
         iEOLs = 1;
      }
   }
   else if( ISARRAY( iParam ) )
   {
      PHB_ITEM pArray = hb_param( iParam, HB_IT_ARRAY );
      ULONG ulSize = hb_arrayLen( pArray );
      for( ul = 1; ul <= ulSize; ++ul )
      {
         if( hb_arrayGetCLen( pArray, ul ) > 0 )
            ++iEOLs;
      }
      if( iEOLs )
      {
         iEOLs = 0;
         pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) * iEOLs );
         for( ul = 1; ul <= ulSize; ++ul )
         {
            ulLen = hb_arrayGetCLen( pArray, ul );
            if( ulLen > 0 )
            {
               pEOLs[ iEOLs ].szEOL = hb_arrayGetCPtr( pArray, ul );
               pEOLs[ iEOLs ].ulLen = ulLen;
               ++iEOLs;
            }
         }
      }
   }
#else
   HB_SYMBOL_UNUSED( iParam );
#endif

   if( iEOLs == 0 )
   {
      pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) );
      if( hb_set.HB_SET_EOL && hb_set.HB_SET_EOL[ 0 ] )
         pEOLs->szEOL = hb_set.HB_SET_EOL;
      else
         pEOLs->szEOL = hb_conNewLine();
      pEOLs->ulLen = strlen( pEOLs->szEOL );
      iEOLs = pEOLs->ulLen ? 1 : 0;
   }

   * piEOLs = iEOLs;
   return pEOLs;
}
Exemple #13
0
static int hb_gt_gui_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
                            int iClrNorm, int iClrHigh, double dDelay )
{
   void * hText;
   LPCTSTR lpText = HB_ITEMGETSTR( pMessage, &hText, NULL );
   int iRet, iOptions = pOptions ? ( int ) hb_arrayLen( pOptions ) : 0;

   if( lpText && iOptions > 0 )
   {
      int i, iType = 0;
      UINT uType;

      for( i = 1; i <= iOptions; ++i )
         iType |= hb_gt_gui_optionId( hb_arrayGetCPtr( pOptions, i ) );

      switch( iType )
      {
         case 0x01:
            uType = MB_OK;
            break;
         case 0x03:
            uType = MB_OKCANCEL;
            break;
         case 0x06:
            uType = MB_RETRYCANCEL;
            break;
         case 0x0E:
#ifdef MB_CANCELTRYCONTINUE
            uType = hb_iswin2k() ? MB_CANCELTRYCONTINUE : MB_ABORTRETRYIGNORE;
#else
            uType = MB_ABORTRETRYIGNORE;
#endif
            break;
         case 0x12:
            uType = MB_OKCANCEL;
            break;
         case 0x21:
            uType = MB_YESNO;
            break;
         case 0x30:
            uType = MB_YESNO;
            break;
         case 0x32:
            uType = MB_YESNOCANCEL;
            break;
         default:
            uType = MB_OK;
            break;
      }

      iRet = MessageBox( NULL, lpText, TEXT( "" ), uType );
      iRet = hb_gt_gui_optionPos( iRet, iType, pOptions );
   }
   else
      iRet = HB_GTSUPER_ALERT( pGT, pMessage, pOptions, iClrNorm,
                               iClrHigh, dDelay );

   hb_strfree( hText );

   return iRet;
}
Exemple #14
0
/* --- SDD METHODS --- */
static HB_ERRCODE odbcConnect( SQLDDCONNECTION * pConnection, PHB_ITEM pItem )
{
   SQLHENV    hEnv     = NULL;
   SQLHDBC    hConnect = NULL;
   char *     szError;
   HB_ERRCODE errCode;

#if ODBCVER >= 0x0300
   if( SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, &hEnv ) ) )
#else
   if( SQL_SUCCEEDED( SQLAllocEnv( &hEnv ) ) )
#endif
   {
#if ODBCVER >= 0x0300
      SQLSetEnvAttr( hEnv, SQL_ATTR_ODBC_VERSION, ( SQLPOINTER ) SQL_OV_ODBC3, SQL_IS_UINTEGER );
#endif

#if ODBCVER >= 0x0300
      if( SQL_SUCCEEDED( SQLAllocHandle( SQL_HANDLE_DBC, hEnv, &hConnect ) ) )
#else
      if( SQL_SUCCEEDED( SQLAllocConnect( hEnv, &hConnect ) ) )
#endif
      {
         const O_HB_CHAR * pchConStr;
         void *            hConnStr;
         HB_SIZE           nConnLen;
         SQLTCHAR          cBuffer[ 1024 ];
         SQLSMALLINT       iLen = HB_SIZEOFARRAY( cBuffer );

         cBuffer[ 0 ] = '\0';
         pchConStr = O_HB_ARRAYGETSTR( pItem, 2, &hConnStr, &nConnLen );

         if( SQL_SUCCEEDED( SQLDriverConnect( hConnect,
                                              NULL,
                                              ( SQLTCHAR * ) HB_UNCONST( pchConStr ),
                                              ( SQLSMALLINT ) nConnLen,
                                              cBuffer,
                                              HB_SIZEOFARRAY( cBuffer ),
                                              &iLen,
                                              SQL_DRIVER_NOPROMPT ) ) )
         {
            hb_strfree( hConnStr );
            pConnection->pSDDConn = hb_xgrab( sizeof( SDDCONN ) );
            ( ( SDDCONN * ) pConnection->pSDDConn )->hConn = hConnect;
            ( ( SDDCONN * ) pConnection->pSDDConn )->hEnv  = hEnv;
            return HB_SUCCESS;
         }
         else
         {
            hb_strfree( hConnStr );
            szError = odbcGetError( hEnv, hConnect, SQL_NULL_HSTMT, &errCode );
            hb_rddsqlSetError( errCode, szError, NULL, NULL, 0 );
            hb_xfree( szError );
         }
#if ODBCVER >= 0x0300
         SQLFreeHandle( SQL_HANDLE_DBC, hConnect );
#else
         SQLFreeConnect( hConnect );
#endif
      }
      else
      {
         szError = odbcGetError( hEnv, SQL_NULL_HDBC, SQL_NULL_HSTMT, &errCode );
         hb_errRT_ODBCDD( EG_OPEN, ESQLDD_CONNALLOC, szError, hb_arrayGetCPtr( pItem, 2 ), errCode );
         hb_xfree( szError );
      }
#if ODBCVER >= 0x0300
      SQLFreeHandle( SQL_HANDLE_ENV, hEnv );
#else
      SQLFreeEnv( hEnv );
#endif
   }
   else
   {
      szError = odbcGetError( SQL_NULL_HENV, SQL_NULL_HDBC, SQL_NULL_HSTMT, &errCode );
      hb_errRT_ODBCDD( EG_OPEN, ESQLDD_ENVALLOC, szError, hb_arrayGetCPtr( pItem, 2 ), errCode );
      hb_xfree( szError );
   }
   return HB_FAILURE;
}
Exemple #15
0
static void hb_mlGetEOLs( PHB_MLC_INFO pMLC, int iParam )
{
   int iEOLs = 0;
   HB_SIZE nLen;

   pMLC->pEOLs = pMLC->EOL_buffer;

/* NOTE: This is a parameter extension (HB_EXTENSION) which breaks
         our effort to keep strict parameter compatibility with
         Clipper 5.x. In this case we've resorted to a compromise
         because there was no other idea which seemed natural enough.
         Clipper will ignore these parameters and use CRLF EOL hard
         coded. [vszakats] */
#ifndef HB_CLP_STRICT /* HB_EXTENSION */
   nLen = hb_parclen( iParam );
   if( nLen )
   {
      pMLC->pEOLs[ 0 ].szEOL = hb_parc( iParam );
      pMLC->pEOLs[ 0 ].nLen = nLen;
      iEOLs = 1;
   }
   else if( HB_ISARRAY( iParam ) )
   {
      PHB_ITEM pArray = hb_param( iParam, HB_IT_ARRAY );
      HB_SIZE nSize = hb_arrayLen( pArray ), n;

      for( n = 1; n <= nSize; ++n )
      {
         if( hb_arrayGetCLen( pArray, n ) > 0 )
            ++iEOLs;
      }
      if( iEOLs )
      {
         if( iEOLs > HB_EOL_BUFFER_SIZE )
            pMLC->pEOLs = ( PHB_EOL_INFO ) hb_xgrab( sizeof( HB_EOL_INFO ) * iEOLs );
         iEOLs = 0;
         for( n = 1; n <= nSize; ++n )
         {
            nLen = hb_arrayGetCLen( pArray, n );
            if( nLen > 0 )
            {
               pMLC->pEOLs[ iEOLs ].szEOL = hb_arrayGetCPtr( pArray, n );
               pMLC->pEOLs[ iEOLs ].nLen = nLen;
               ++iEOLs;
            }
         }
      }
   }
#else
   HB_SYMBOL_UNUSED( iParam );
   HB_SYMBOL_UNUSED( nLen );
#endif

   if( iEOLs == 0 )
   {
      pMLC->pEOLs[ 0 ].szEOL = hb_setGetEOL();
      if( ! pMLC->pEOLs[ 0 ].szEOL || ! pMLC->pEOLs[ 0 ].szEOL[ 0 ] )
         pMLC->pEOLs[ 0 ].szEOL = hb_conNewLine();
      pMLC->pEOLs[ 0 ].nLen = strlen( pMLC->pEOLs[ 0 ].szEOL );
      iEOLs = pMLC->pEOLs[ 0 ].nLen ? 1 : 0;
   }

   pMLC->iEOLs = iEOLs;
}
Exemple #16
0
/*
 * Retrieve information about the current table/driver.
 */
static HB_ERRCODE hb_delimInfo( DELIMAREAP pArea, HB_USHORT uiIndex, PHB_ITEM pItem )
{
   HB_TRACE( HB_TR_DEBUG, ( "hb_delimInfo(%p,%hu,%p)", pArea, uiIndex, pItem ) );

   switch( uiIndex )
   {
      case DBI_CANPUTREC:
         hb_itemPutL( pItem, pArea->fTransRec );
         break;

      case DBI_GETRECSIZE:
         hb_itemPutNL( pItem, pArea->uiRecordLen );
         break;

      case DBI_GETDELIMITER:
      {
         char szDelim[ 2 ];
         szDelim[ 0 ] = pArea->cDelim;
         szDelim[ 1 ] = '\0';
         hb_itemPutC( pItem, szDelim );
         break;
      }
      case DBI_SETDELIMITER:
         if( hb_itemType( pItem ) & HB_IT_STRING )
         {
            const char * szDelim = hb_itemGetCPtr( pItem );

            if( hb_stricmp( szDelim, "BLANK" ) == 0 )
            {
               pArea->cDelim = '\0';
               pArea->cSeparator = ' ';
            }
#ifndef HB_CLP_STRICT
            else if( hb_stricmp( szDelim, "PIPE" ) == 0 )
            {
               pArea->cDelim = '\0';
               pArea->cSeparator = '|';
            }
            else if( hb_stricmp( szDelim, "TAB" ) == 0 )
            {
               pArea->cDelim = '\0';
               pArea->cSeparator = '\t';
            }
            else
#else
            else if( *szDelim )
#endif
            {
               pArea->cDelim = *szDelim;
            }
         }
         /*
          * a small trick which allow to set character field delimiter and
          * field separator in COPY TO ... and APPEND FROM ... commands as
          * array. F.e.:
          *    COPY TO test DELIMITED WITH ({"","|"})
          */
#ifndef HB_CLP_STRICT
         else if( hb_itemType( pItem ) & HB_IT_ARRAY )
         {
            char cSeparator;

            if( hb_arrayGetType( pItem, 1 ) & HB_IT_STRING )
               pArea->cDelim = *hb_arrayGetCPtr( pItem, 1 );

            cSeparator = *hb_arrayGetCPtr( pItem, 2 );
            if( cSeparator )
               pArea->cSeparator = cSeparator;
         }
#endif
         break;

      case DBI_SEPARATOR:
      {
         char szSeparator[ 2 ];
         const char * szNew = hb_itemGetCPtr( pItem );
         szSeparator[ 0 ] = pArea->cSeparator;
         szSeparator[ 1 ]  = '\0';
         if( *szNew )
            pArea->cSeparator = *szNew;
         hb_itemPutC( pItem, szSeparator );
         break;
      }
      case DBI_FULLPATH:
         hb_itemPutC( pItem, pArea->szFileName);
         break;

      case DBI_FILEHANDLE:
         hb_itemPutNInt( pItem, ( HB_NHANDLE ) hb_fileHandle( pArea->pFile ) );
         break;

      case DBI_SHARED:
         hb_itemPutL( pItem, pArea->fShared );
         break;

      case DBI_ISREADONLY:
         hb_itemPutL( pItem, pArea->fReadonly );
         break;

      case DBI_POSITIONED:
         hb_itemPutL( pItem, pArea->fPositioned );
         break;

      case DBI_DB_VERSION:
      case DBI_RDD_VERSION:
      {
         char szBuf[ 64 ];
         int iSub = hb_itemGetNI( pItem );

         if( iSub == 1 )
            hb_snprintf( szBuf, sizeof( szBuf ), "%d.%d (%s)", 0, 1, "DELIM" );
         else if( iSub == 2 )
            hb_snprintf( szBuf, sizeof( szBuf ), "%d.%d (%s:%d)", 0, 1, "DELIM", pArea->area.rddID );
         else
            hb_snprintf( szBuf, sizeof( szBuf ), "%d.%d", 0, 1 );
         hb_itemPutC( pItem, szBuf );
         break;
      }

      default:
         return SUPER_INFO( &pArea->area, uiIndex, pItem );
   }
Exemple #17
0
int hb_CmpTdSpan( const char * szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBlock, BOOL bOverWrite, const char * szPassWord, int iSpanSize, BOOL bPath, BOOL bDrive, PHB_ITEM pProgress )
{
   ULONG                ulCount     = 0;
   const char *         szDummy;
   DWORD                dwSize;
   BOOL                 bAdded      = FALSE;
   BOOL                 bReturn     = TRUE;
   BOOL                 bFileExist  = hb_fsFile( szFile );

   CZipArchive          szZip;
   SpanCallbackc        span;
   SpanActionCallbackc  spanac;

   szZip.SetSpanCallback( &span );


   if( iSpanSize == 0 )
   {
      iSpanSize = 1457664;
   }

   try
   {
      if( ( bFileExist && bOverWrite ) || ! bFileExist )
      {
         szZip.Open( szFile, CZipArchive::zipCreateSpan, iSpanSize );
      }
      else
      {
         bReturn = FALSE;
         return ( int ) bReturn;
      }
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }

   //if (! bReturn )
   //{

   if( szPassWord != NULL )
   {
      szZip.SetPassword( szPassWord );
   }

   if( pZipI.szComment != NULL )
   {
      szZip.SetGlobalComment( pZipI.szComment );
      hb_xfree( pZipI.szComment );
   }

   if( HB_IS_BLOCK( pProgress ) )
   {
      pProgressInfo = pProgress;
      szZip.SetCallback( &spanac );
   }

   for( ulCount = 1; ( ulCount <= hb_arrayLen( pArray ) ); ulCount++ )
   {
      szDummy  = ( char * ) hb_arrayGetCPtr( pArray, ulCount );
      dwSize   = GetCurrentFileSize( szDummy );

      bAdded   = FALSE;

      if( dwSize != ( DWORD ) -1 )
      {
         if( pBlock != NULL )
         {
            PHB_ITEM FileName = hb_itemPutC( NULL, hb_arrayGetCPtr( pArray, ulCount ) ), FilePos = hb_itemPutNI( NULL, ulCount );

            hb_vmEvalBlockV( pBlock, 2, FileName, FilePos );

            hb_itemRelease( FileName );
            hb_itemRelease( FilePos );
         }

         try
         {

            if( bPath && ! bAdded )
            {
               szZip.AddNewFile( szDummy, iCompLevel, true, CZipArchive::zipsmSafeSmart, 65536 );
               bAdded = TRUE;
            }
            else if( ! bDrive && ! bPath && ! bAdded )
            {
               szZip.AddNewFile( szDummy, iCompLevel, false, CZipArchive::zipsmSafeSmart, 65536 );
            }

         }
         catch( ... )
         {
         }
      }
   }
   //}

   try
   {
      szZip.Close();
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }


   return ( int ) bReturn;
}
Exemple #18
0
int hb_CompressFile( const char * szFile, PHB_ITEM pArray, int iCompLevel, PHB_ITEM pBlock, BOOL bOverWrite, const char * szPassWord, BOOL bPath, BOOL bDrive, PHB_ITEM pProgress )
{
   ULONG                ulCount        = 0;
   const char *         szDummy;
   char *               szDummyLower   = NULL;
   char *               szFileLower    = hb_strdup( ( char * ) szFile );
   BOOL                 bFileExist     = hb_fsFile( szFile );
   BOOL                 bAdded         = FALSE;
   BOOL                 bReturn        = TRUE;
   DWORD                dwSize;

   CZipArchive          szZip;
   SpanCallbackc        span;
   SpanActionCallbackc  spanac;

   szZip.SetSpanCallback( &span );

   #ifdef HB_OS_WIN_32
   hb_strLower( szFileLower, strlen( szFileLower ) );
   #endif

   try
   {
      if( ( bFileExist && bOverWrite ) || ! bFileExist )
      {
         szZip.Open( szFile, CZipArchive::zipCreate, 0 );
      }
      else
      {
         szZip.Open( szFile, CZipArchive::zipOpen, 0 );
      }
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }

   if( bReturn )
   {

      if( szPassWord != NULL )
      {
         szZip.SetPassword( szPassWord );
      }

      if( pZipI.szComment != NULL )
      {
         szZip.SetGlobalComment( pZipI.szComment );
         hb_xfree( pZipI.szComment );
      }

      if( HB_IS_BLOCK( pProgress ) )
      {
         pProgressInfo = pProgress;
         szZip.SetCallback( &spanac );
      }

      for( ulCount = 1; ( ulCount <= hb_arrayLen( pArray ) ); ulCount++ )
      {
         szDummy        = ( char * ) hb_arrayGetCPtr( pArray, ulCount );
         dwSize         = GetCurrentFileSize( szDummy );
         bAdded         = FALSE;

         szDummyLower   = hb_strdup( ( char * ) szDummy );

         #ifdef HB_OS_WIN_32
         hb_strLower( szDummyLower, strlen( szDummyLower ) );
         #endif

// Prevent adding current archive file !
         if( strstr( szFileLower, szDummyLower ) == NULL && strstr( szDummyLower, szFileLower ) == NULL )
         {
            if( dwSize != ( DWORD ) -1 )
            {
               if( pBlock != NULL )
               {
                  PHB_ITEM FileName = hb_itemPutC( NULL, hb_arrayGetCPtr( pArray, ulCount ) ), FilePos = hb_itemPutNI( NULL, ulCount );


                  hb_vmEvalBlockV( pBlock, 2, FileName, FilePos );

                  hb_itemRelease( FileName );
                  hb_itemRelease( FilePos );
               }

               try
               {
                  if( bPath && ! bAdded )
                  {
                     szZip.AddNewFile( szDummy, iCompLevel, true, CZipArchive::zipsmSafeSmart, 65536 );
                     bAdded = TRUE;
                  }
                  else if( ! bDrive && ! bPath && ! bAdded )
                  {
                     szZip.AddNewFile( szDummy, iCompLevel, false, CZipArchive::zipsmSafeSmart, 65536 );
                  }

               }
               catch( ... )
               {
               }
            }
         }
         hb_xfree( szDummyLower );
      }
   }
   hb_xfree( szFileLower );
   try
   {
      szZip.Close();
   }

   catch( CZipException )
   {
      bReturn = FALSE;
   }

   catch( ... )
   {
   }

   return ( int ) bReturn;


}
Exemple #19
0
static HB_ERRCODE sqlbaseRddInfo( LPRDDNODE pRDD, HB_USHORT uiIndex, HB_ULONG ulConnect, PHB_ITEM pItem )
{
   HB_ULONG ulConn;
   SQLDDCONNECTION * pConn;

   HB_SYMBOL_UNUSED( pRDD );

   ulConn = ulConnect ? ulConnect : s_ulConnectionCurrent;
   if( ulConn > 0 && ulConn <= s_ulConnectionCount )
      pConn = s_pConnection[ ulConn - 1 ];
   else
      pConn = NULL;

   switch( uiIndex )
   {
      case RDDI_REMOTE:
         hb_itemPutL( pItem, HB_TRUE );
         break;

      case RDDI_CONNECTION:
      {
         HB_ULONG ulNewConnection = 0;

         if( hb_itemType( pItem ) & HB_IT_NUMERIC )
            ulNewConnection = hb_itemGetNL( pItem );

         hb_itemPutNL( pItem, ulConnect ? ulConnect : s_ulConnectionCurrent );

         if( ulNewConnection )
            s_ulConnectionCurrent = ulNewConnection;
         break;
      }

      case RDDI_ISDBF:
         hb_itemPutL( pItem, HB_FALSE );
         break;

      case RDDI_CANPUTREC:
         hb_itemPutL( pItem, HB_TRUE );
         break;

      case RDDI_CONNECT:
      {
         PSDDNODE     pNode = NULL;
         HB_ULONG     ul;
         const char * pStr;

         pStr = hb_arrayGetCPtr( pItem, 1 );
         if( pStr )
         {
            pNode = s_pSdd;
            while( pNode )
            {
               if( ! hb_stricmp( pNode->Name, pStr ) )
                  break;
               pNode = pNode->pNext;
            }
         }

         hb_rddsqlSetError( 0, NULL, NULL, NULL, 0 );
         pConn = ( SQLDDCONNECTION * ) hb_xgrab( sizeof( SQLDDCONNECTION ) );
         memset( pConn, 0, sizeof( SQLDDCONNECTION ) );
         if( pNode && pNode->Connect( pConn, pItem ) == HB_SUCCESS )
         {
            pConn->pSDD = pNode;

            /* Find free connection handle */
            for( ul = 0; ul < s_ulConnectionCount; ul++ )
            {
               if( ! s_pConnection[ ul ] )
                  break;
            }
            if( ul >= s_ulConnectionCount )
            {
               /* Realloc connection table */
               if( s_pConnection )
                  s_pConnection = ( SQLDDCONNECTION ** ) hb_xrealloc( s_pConnection, sizeof( SQLDDCONNECTION * ) * ( s_ulConnectionCount + CONNECTION_LIST_EXPAND ) );
               else
                  s_pConnection = ( SQLDDCONNECTION ** ) hb_xgrab( sizeof( SQLDDCONNECTION * ) * CONNECTION_LIST_EXPAND );

               memset( s_pConnection + s_ulConnectionCount, 0, sizeof( SQLDDCONNECTION * ) * CONNECTION_LIST_EXPAND );
               ul = s_ulConnectionCount;
               s_ulConnectionCount += CONNECTION_LIST_EXPAND;
            }
            s_pConnection[ ul ] = pConn;
            ul++;
            s_ulConnectionCurrent = ul;
         }
         else
         {
            hb_xfree( pConn );
            ul = 0;
         }

         hb_itemPutNI( pItem, ul );
         break;
      }

      case RDDI_DISCONNECT:
         hb_rddsqlSetError( 0, NULL, NULL, NULL, 0 );
         if( pConn && ! pConn->uiAreaCount && pConn->pSDD->Disconnect( pConn ) == HB_SUCCESS )
         {
            hb_xfree( pConn );
            s_pConnection[ ulConn - 1 ] = NULL;
            if( s_ulConnectionCurrent == ulConn )
               s_ulConnectionCurrent = 0;

            hb_itemPutL( pItem, HB_TRUE );
            return HB_SUCCESS;
         }
         hb_itemPutL( pItem, HB_FALSE );
         return HB_SUCCESS;

      case RDDI_EXECUTE:
         hb_rddsqlSetError( 0, NULL, NULL, NULL, 0 );
         if( pConn )
            hb_itemPutL( pItem, pConn->pSDD->Execute( pConn, pItem ) == HB_SUCCESS );
         else
            hb_itemPutL( pItem, HB_FALSE );

         return HB_SUCCESS;

      case RDDI_ERROR:
         hb_itemPutC( pItem, s_szError );
         return HB_SUCCESS;

      case RDDI_ERRORNO:
         hb_itemPutNI( pItem, s_errCode );
         return HB_SUCCESS;

      case RDDI_QUERY:
         hb_itemPutC( pItem, s_szQuery );
         return HB_SUCCESS;

      case RDDI_NEWID:
         hb_itemCopy( pItem, s_pItemNewID );
         return HB_SUCCESS;

      case RDDI_AFFECTEDROWS:
         hb_itemPutNInt( pItem, s_ulAffectedRows );
         return HB_SUCCESS;

#if 0
      default:
         return SUPER_RDDINFO( pRDD, uiIndex, ulConnect, pItem );
#endif

   }

   return HB_SUCCESS;
}
Exemple #20
0
static void hb_compGenArgList( int iFirst, int iLast,
                               int * pArgC, const char *** pArgV,
                               PHB_ITEM * pIncItem,
                               PHB_PP_OPEN_FUNC * pOpenFunc,
                               PHB_PP_MSG_FUNC * pMsgFunc )
{
   PHB_ITEM pParam;
   HB_SIZE ul, nLen;
   int argc = 1, i;
   const char ** argv;

   if( pMsgFunc )
   {
      *pMsgFunc = NULL;
      if( HB_ISLOG( iFirst ) )
      {
         if( hb_parl( iFirst ) )
            *pMsgFunc = s_pp_msg;
         ++iFirst;
      }
   }

   if( pIncItem && pOpenFunc )
   {
      *pOpenFunc = NULL;
      *pIncItem = hb_param( iFirst, HB_IT_HASH );
      if( *pIncItem )
      {
         ++iFirst;
         *pOpenFunc = s_pp_openFile;
      }
   }

   for( i = iFirst; i <= iLast; ++i )
   {
      pParam = hb_param( i, HB_IT_ARRAY | HB_IT_STRING );
      if( pParam )
      {
         if( HB_IS_ARRAY( pParam ) )
         {
            ul = hb_arrayLen( pParam );
            if( ul )
            {
               do
               {
                  if( hb_arrayGetType( pParam, ul ) & HB_IT_STRING )
                     ++argc;
               }
               while( --ul );
            }
         }
         else if( HB_IS_STRING( pParam ) )
            ++argc;
      }
   }

   argv = ( const char ** ) hb_xgrab( sizeof( char * ) * ( argc + 1 ) );
   argc = 0;
   for( i = iFirst; i <= iLast; ++i )
   {
      pParam = hb_param( i, HB_IT_ARRAY | HB_IT_STRING );
      if( pParam )
      {
         if( HB_IS_ARRAY( pParam ) )
         {
            nLen = hb_arrayLen( pParam );
            for( ul = 1; ul <= nLen; ++ul )
            {
               if( hb_arrayGetType( pParam, ul ) & HB_IT_STRING )
                  argv[ argc++ ] = hb_arrayGetCPtr( pParam, ul );
            }
         }
         else if( HB_IS_STRING( pParam ) )
            argv[ argc++ ] = hb_itemGetCPtr( pParam );
      }
   }
   argv[ argc ] = NULL;

   *pArgC = argc;
   *pArgV = argv;
}