static HB_FATTR hb_translateExtAttr( const char * szFileName, HB_FATTR ulExtAttr ) { int iLen; iLen = ( int ) strlen( szFileName ); if( ( iLen > 4 && ( hb_stricmp( szFileName + iLen - 4, ".exe" ) == 0 || hb_stricmp( szFileName + iLen - 4, ".com" ) == 0 || hb_stricmp( szFileName + iLen - 4, ".bat" ) == 0 || hb_stricmp( szFileName + iLen - 4, ".cmd" ) == 0 ) ) || ( iLen > 3 && hb_stricmp( szFileName + iLen - 3, ".sh" ) == 0 ) ) { ulExtAttr |= 0x00490000; /* --x--x--x */ } if( ulExtAttr & HB_FA_READONLY ) ulExtAttr |= 0x01240000; /* r--r--r-- */ else ulExtAttr |= 0x01B60000; /* rw-rw-rw- */ if( ulExtAttr & HB_FA_DIRECTORY ) ulExtAttr |= 0x40000000; else ulExtAttr |= 0x80000000; return ulExtAttr; }
/* * Retrieve information about the current table/driver. */ static HB_ERRCODE hb_delimInfo( DELIMAREAP pArea, 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 ) { char * szDelim = hb_itemGetCPtr( pItem ); if( hb_stricmp( szDelim, "BLANK" ) == 0 ) { pArea->cDelim = '\0'; pArea->cSeparator = ' '; } #ifndef HB_C52_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_C52_STRICT else if( hb_itemType( pItem ) & HB_IT_ARRAY )
int hb_tr_level( void ) { if( s_level == -1 ) { char env[ HB_PATH_MAX ]; int enabled = s_enabled; /* protection against recursive or concurrent calls */ s_enabled = 0; s_level = HB_TR_DEFAULT; if( s_fp == NULL ) { if( hb_getenv_buffer( "HB_TR_OUTPUT", env, sizeof( env ) ) && env[ 0 ] != '\0' ) { s_fp = hb_fopen( env, s_mode ); if( s_fp == NULL ) s_fp = stderr; } else s_fp = stderr; } if( hb_getenv_buffer( "HB_TR_LEVEL", env, sizeof( env ) ) && env[ 0 ] != '\0' ) { int i; for( i = 0; i < HB_TR_LAST; ++i ) { if( hb_stricmp( env, s_slevel[ i ] ) == 0 || hb_stricmp( env, s_slevel[ i ] + 6 ) == 0 ) { s_level = i; break; } } } if( s_sysout < 0 ) { s_sysout = ( hb_getenv_buffer( "HB_TR_SYSOUT", env, sizeof( env ) ) && env[ 0 ] != '\0' ) ? 1 : 0; } if( s_flush < 0 ) { s_flush = ( hb_getenv_buffer( "HB_TR_FLUSH", env, sizeof( env ) ) && env[ 0 ] != '\0' ) ? 1 : 0; } s_enabled = enabled; } return s_level; }
int hb_sddRegister( PSDDNODE pSdd ) { PSDDNODE pNode = s_pSdd; /* "Inheritance" from NULL SDD */ if( pSdd->Connect == NULL ) pSdd->Connect = sddNull.Connect; if( pSdd->Disconnect == NULL ) pSdd->Disconnect = sddNull.Disconnect; if( pSdd->Execute == NULL ) pSdd->Execute = sddNull.Execute; if( pSdd->Open == NULL ) pSdd->Open = sddNull.Open; if( pSdd->Close == NULL ) pSdd->Close = sddNull.Close; if( pSdd->GoTo == NULL ) pSdd->GoTo = sddNull.GoTo; if( pSdd->GetValue == NULL ) pSdd->GetValue = sddNull.GetValue; if( pSdd->GetVarLen == NULL ) pSdd->GetVarLen = sddNull.GetVarLen; while( pNode ) { if( ! hb_stricmp( pNode->Name, pSdd->Name ) ) return 0; pNode = pNode->pNext; } pSdd->pNext = s_pSdd; s_pSdd = pSdd; return 1; }
int hb_sockexRegister( const HB_SOCKET_FILTER * pFilter ) { if( s_iFilterCount == 0 ) s_socketFilters[ s_iFilterCount++ ] = &s_sockFilter; if( pFilter ) { int i; for( i = 0; i < s_iFilterCount; ++i ) { if( s_socketFilters[ i ] == pFilter ) return 1; if( hb_stricmp( s_socketFilters[ i ]->pszName, pFilter->pszName ) == 0 ) return 2; } if( s_iFilterCount >= HB_SOCKET_FILTER_MAX ) return 3; s_socketFilters[ s_iFilterCount++ ] = pFilter; } return 0; }
static void hb_pp_fileIncluded( void * cargo, const char * szFileName ) { HB_COMP_DECL = ( PHB_COMP ) cargo; PHB_INCLST pIncFile, * pIncFilePtr; int iLen; pIncFilePtr = &HB_COMP_PARAM->incfiles; while( *pIncFilePtr ) { #if defined( HB_OS_UNIX ) if( strcmp( ( *pIncFilePtr )->szFileName, szFileName ) == 0 ) return; #else if( hb_stricmp( ( *pIncFilePtr )->szFileName, szFileName ) == 0 ) return; #endif pIncFilePtr = &( *pIncFilePtr )->pNext; } iLen = ( int ) strlen( szFileName ); pIncFile = ( PHB_INCLST ) hb_xgrab( sizeof( HB_INCLST ) + iLen ); pIncFile->pNext = NULL; memcpy( pIncFile->szFileName, szFileName, iLen + 1 ); *pIncFilePtr = pIncFile; }
static PHB_IOUSR s_iousrAddNew( const char * pszPrefix ) { PHB_IOUSR pIO = NULL; int iCount; HB_IOUSR_LOCK(); iCount = s_iCount; while( --iCount >= 0 ) { if( hb_stricmp( pszPrefix, s_ioUsrs[ iCount ]->prefix ) == 0 ) break; } if( iCount < 0 ) { if( s_iCount == 0 ) hb_vmAtQuit( s_iousrFreeAll, NULL ); pIO = ( PHB_IOUSR ) hb_xgrabz( sizeof( HB_IOUSR ) ); pIO->prefix = hb_strdup( pszPrefix ); pIO->prefix_len = ( int ) strlen( pszPrefix ); s_ioUsrs[ s_iCount++ ] = pIO; } HB_IOUSR_UNLOCK(); return pIO; }
static PMIXTAG mixFindTag( ADSXAREAP pArea, PHB_ITEM pOrder ) { char szTag[ MIX_MAXTAGNAMELEN + 1 ]; PMIXTAG pTag; if( HB_IS_NUMBER( pOrder ) ) { UNSIGNED16 usOrder = 0, usFind; usFind = ( UNSIGNED16 ) hb_itemGetNI( pOrder ); AdsGetNumIndexes( pArea->adsarea.hTable, &usOrder ); usOrder++; pTag = pArea->pTagList; while( pTag && usOrder != usFind ) pTag = pTag->pNext; } else { hb_strncpyUpperTrim( szTag, hb_itemGetCPtr( pOrder ), MIX_MAXTAGNAMELEN ); pTag = pArea->pTagList; while( pTag && hb_stricmp( szTag, pTag->szName ) ) pTag = pTag->pNext; } return pTag; }
static int s_socket_filter_find( const char * pszFilter ) { int i; for( i = 0; i < s_iFilterCount; ++i ) { if( hb_stricmp( s_socketFilters[ i ]->pszName, pszFilter ) == 0 ) return i; } return -1; }
static int hb_i18n_pluralformfind( const char * szLang ) { int i; for( i = 0; i < ( int ) HB_PLURAL_FOMRS_COUNT; ++i ) { if( hb_stricmp( szLang, s_plural_forms[ i ].szLangID ) == 0 ) return s_plural_forms[ i ].iForm; } if( strlen( szLang ) > 2 ) { for( i = 0; i < ( int ) HB_PLURAL_FOMRS_COUNT; ++i ) { if( hb_strnicmp( szLang, s_plural_forms[ i ].szLangID, 2 ) == 0 ) return s_plural_forms[ i ].iForm; } } return 0; }
static void hb_compChkDefineSwitch( HB_COMP_DECL, const char * pszSwitch ) { if( pszSwitch && HB_ISOPTSEP( pszSwitch[ 0 ] ) ) { if( pszSwitch[ 1 ] == 'd' || pszSwitch[ 1 ] == 'D' ) { if( pszSwitch[ 2 ] ) { char * szDefText = hb_strdup( pszSwitch + 2 ), * szAssign; szAssign = strchr( szDefText, '=' ); if( szAssign ) *szAssign++ = '\0'; hb_pp_addDefine( HB_COMP_PARAM->pLex->pPP, szDefText, szAssign ); hb_xfree( szDefText ); } } else if( ( pszSwitch[ 1 ] == 'U' || pszSwitch[ 1 ] == 'u' ) && ( pszSwitch[ 2 ] == 'N' || pszSwitch[ 2 ] == 'n' ) && ( pszSwitch[ 3 ] == 'D' || pszSwitch[ 3 ] == 'd' ) && ( pszSwitch[ 4 ] == 'E' || pszSwitch[ 4 ] == 'e' ) && ( pszSwitch[ 5 ] == 'F' || pszSwitch[ 5 ] == 'f' ) && pszSwitch[ 6 ] == ':' ) { char *szDefText = hb_strdup( pszSwitch + 7 ); unsigned int i = 0; while( szDefText[ i ] && ! HB_ISOPTSEP( szDefText[ i ] ) ) { i++; } szDefText[ i ] = '\0'; if( szDefText[ 0 ] ) { if( hb_stricmp( szDefText, ".ARCH." ) == 0 ) hb_pp_delDefine( HB_COMP_PARAM->pLex->pPP, szDefText ); } hb_xfree( szDefText ); } } }
static const char * s_findExtMimeType( const char * cExt ) { int iCount; for( iCount = 0; iCount < EXT_MIME_TABLE_SIZE; iCount++ ) { if( s_extMimeTable[ iCount ].flags == MIME_FLAG_CASEINSENS ) { if( hb_stricmp( cExt, s_extMimeTable[ iCount ].pattern ) == 0 ) return s_extMimeTable[ iCount ].mime_type; } else { if( strcmp( cExt, s_extMimeTable[ iCount ].pattern ) == 0 ) return s_extMimeTable[ iCount ].mime_type; } } return NULL; }
static PHB_LANG_BASE hb_langFindBase( const char * pszID ) { PHB_LANG_BASE pBase = NULL; if( pszID ) { int iPos; for( iPos = 0; iPos < HB_LANG_MAX_; iPos++ ) { if( s_langList[ iPos ].lang != NULL ) { if( hb_stricmp( s_langList[ iPos ].lang->pItemList[ HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ], pszID ) == 0 ) return &s_langList[ iPos ]; } else if( pBase == NULL ) pBase = &s_langList[ iPos ]; } } return pBase; }
HB_BOOL hb_sockexItemSetFilter( PHB_ITEM pItem, const char * pszFilter, PHB_ITEM pParams ) { PHB_SOCKEX * pSockPtr = ( PHB_SOCKEX * ) hb_itemGetPtrGC( pItem, &s_gcSocketFuncs ); if( pSockPtr && *pSockPtr ) { PHB_SOCKEX pSock = *pSockPtr; if( pszFilter == NULL ? pSock->pFilter == &s_sockFilter : ! hb_stricmp( pSock->pFilter->pszName, pszFilter ) ) return HB_TRUE; else { PHB_SOCKEX pSockNew = hb_sockexNext( pSock, pszFilter, pParams ); if( pSockNew ) { *pSockPtr = pSockNew; return HB_TRUE; } } } return HB_FALSE; }
HB_ERRCODE hb_dbTransStruct( AREAP lpaSource, AREAP lpaDest, LPDBTRANSINFO lpdbTransInfo, PHB_ITEM * pStruct, PHB_ITEM pFields ) { HB_USHORT uiFields, uiSize, uiCount, uiPosSrc, uiPosDst, uiSizeSrc, uiSizeDst; HB_ERRCODE errCode; const char * szField; HB_BOOL fAll; errCode = SELF_FIELDCOUNT( lpaSource, &uiSizeSrc ); if( errCode != HB_SUCCESS ) return errCode; if( lpaDest ) { errCode = SELF_FIELDCOUNT( lpaDest, &uiSizeDst ); if( errCode != HB_SUCCESS ) return errCode; uiSize = HB_MIN( uiSizeDst, uiSizeSrc ); } else { uiSize = uiSizeDst = uiSizeSrc; } if( ! uiSize ) return HB_FAILURE; if( hb_itemType( pFields ) & HB_IT_ARRAY ) { uiFields = ( HB_USHORT ) hb_arrayLen( pFields ); if( uiFields ) uiSize = uiFields; } else uiFields = 0; fAll = ( uiSizeDst == uiSizeSrc ); lpdbTransInfo->lpaSource = lpaSource; lpdbTransInfo->lpaDest = lpaDest; lpdbTransInfo->lpTransItems = ( LPDBTRANSITEM ) hb_xgrab( uiSize * sizeof( DBTRANSITEM ) ); if( ! lpaDest ) { *pStruct = hb_itemNew( NULL ); hb_arrayNew( *pStruct, 0 ); } if( uiFields == 0 ) { if( lpaDest ) { PHB_ITEM pItem = hb_itemNew( NULL ); uiSize = 0; for( uiCount = 1; uiCount <= uiSizeSrc; ++uiCount ) { if( SELF_FIELDINFO( lpaSource, uiCount, DBS_NAME, pItem ) != HB_SUCCESS ) { uiSize = 0; break; } szField = hb_itemGetCPtr( pItem ); uiPosDst = hb_rddFieldExpIndex( lpaDest, szField ); if( uiPosDst != uiCount ) fAll = HB_FALSE; if( uiPosDst ) { HB_USHORT ui; /* check for replicated field names in source area */ for( ui = 0; ui < uiSize; ++ui ) { if( lpdbTransInfo->lpTransItems[ ui ].uiDest == uiPosDst ) break; } if( ui == uiSize ) { lpdbTransInfo->lpTransItems[ uiSize ].uiSource = uiCount; lpdbTransInfo->lpTransItems[ uiSize++ ].uiDest = uiPosDst; } } } hb_itemRelease( pItem ); } else { hb_tblStructure( lpaSource, *pStruct, 0 ); uiSize = ( HB_USHORT ) hb_arrayLen( *pStruct ); for( uiCount = 0; uiCount < uiSize; ++uiCount ) { lpdbTransInfo->lpTransItems[ uiCount ].uiSource = lpdbTransInfo->lpTransItems[ uiCount ].uiDest = uiCount + 1; } } } else { uiSize = 0; for( uiCount = 1; uiCount <= uiFields; ++uiCount ) { szField = hb_dbTransFieldPos( pFields, uiCount ); if( szField ) { uiPosSrc = hb_rddFieldExpIndex( lpaSource, szField ); if( ! uiPosSrc ) continue; if( lpaDest ) uiPosDst = hb_rddFieldExpIndex( lpaDest, szField ); else uiPosDst = uiSize + 1; if( uiPosDst ) { if( uiPosSrc != uiPosDst ) fAll = HB_FALSE; lpdbTransInfo->lpTransItems[ uiSize ].uiSource = uiPosSrc; lpdbTransInfo->lpTransItems[ uiSize++ ].uiDest = uiPosDst; if( ! lpaDest ) { hb_arraySize( *pStruct, uiSize ); hb_fldStructure( lpaSource, uiPosSrc, 0, hb_arrayGetItemPtr( *pStruct, uiSize ) ); } } } } } if( uiSize != uiSizeSrc ) fAll = HB_FALSE; if( fAll && lpaDest ) { PHB_ITEM pSrcItm = hb_itemNew( NULL ), pDstItm = hb_itemNew( NULL ); /* * if fAll is HB_TRUE here then it means that all fields are included * and they are on the same positions in both tables, so now check * if their types and sizes are also equal */ for( uiCount = 1; uiCount <= uiSize; ++uiCount ) { if( SELF_FIELDINFO( lpaSource, uiCount, DBS_TYPE, pSrcItm ) != HB_SUCCESS || SELF_FIELDINFO( lpaDest, uiCount, DBS_TYPE, pDstItm ) != HB_SUCCESS ) { uiSize = 0; break; } if( hb_stricmp( hb_itemGetCPtr( pSrcItm ), hb_itemGetCPtr( pDstItm ) ) != 0 ) { fAll = HB_FALSE; break; } if( SELF_FIELDINFO( lpaSource, uiCount, DBS_LEN, pSrcItm ) != HB_SUCCESS || SELF_FIELDINFO( lpaDest, uiCount, DBS_LEN, pDstItm ) != HB_SUCCESS ) { uiSize = 0; break; } if( hb_itemGetNL( pSrcItm ) != hb_itemGetNL( pDstItm ) ) { fAll = HB_FALSE; break; } if( SELF_FIELDINFO( lpaSource, uiCount, DBS_DEC, pSrcItm ) != HB_SUCCESS || SELF_FIELDINFO( lpaDest, uiCount, DBS_DEC, pDstItm ) != HB_SUCCESS ) { uiSize = 0; break; } if( hb_itemGetNL( pSrcItm ) != hb_itemGetNL( pDstItm ) ) { fAll = HB_FALSE; break; } #ifdef DBS_FLAG if( SELF_FIELDINFO( lpaSource, uiCount, DBS_FLAG, pSrcItm ) != HB_SUCCESS || SELF_FIELDINFO( lpaDest, uiCount, DBS_FLAG, pDstItm ) != HB_SUCCESS ) { uiSize = 0; break; } if( hb_itemGetNL( pSrcItm ) != hb_itemGetNL( pDstItm ) ) { fAll = HB_FALSE; break; } #endif } hb_itemRelease( pSrcItm ); hb_itemRelease( pDstItm ); } lpdbTransInfo->uiFlags = fAll ? DBTF_MATCH : 0; lpdbTransInfo->uiItemCount = uiSize; return uiSize ? HB_SUCCESS : HB_FAILURE; }
static HB_BOOL hb_pp_CompilerSwitch( void * cargo, const char * szSwitch, int * piValue, HB_BOOL fSet ) { HB_COMP_DECL = ( PHB_COMP ) cargo; HB_BOOL fError = HB_FALSE; int iValue, i; iValue = *piValue; i = ( int ) strlen( szSwitch ); if( i > 1 && ( ( int ) ( szSwitch[ i - 1 ] - '0' ) ) == iValue ) --i; if( i == 1 ) { switch( szSwitch[ 0 ] ) { case 'a': case 'A': if( fSet ) HB_COMP_PARAM->fAutoMemvarAssume = iValue != 0; else iValue = HB_COMP_PARAM->fAutoMemvarAssume ? 1 : 0; break; case 'b': case 'B': if( fSet ) HB_COMP_PARAM->fDebugInfo = iValue != 0; else iValue = HB_COMP_PARAM->fDebugInfo ? 1 : 0; break; case 'j': case 'J': if( fSet ) HB_COMP_PARAM->fI18n = iValue != 0; else iValue = HB_COMP_PARAM->fI18n ? 1 : 0; break; case 'l': case 'L': if( fSet ) HB_COMP_PARAM->fLineNumbers = iValue != 0; else iValue = HB_COMP_PARAM->fLineNumbers ? 1 : 0; break; case 'n': case 'N': if( fSet ) fError = HB_TRUE; else iValue = HB_COMP_PARAM->iStartProc; break; case 'p': case 'P': if( fSet ) HB_COMP_PARAM->fPPO = iValue != 0; else iValue = HB_COMP_PARAM->fPPO ? 1 : 0; break; case 'q': case 'Q': if( fSet ) HB_COMP_PARAM->fQuiet = iValue != 0; else iValue = HB_COMP_PARAM->fQuiet ? 1 : 0; break; case 'v': case 'V': if( fSet ) HB_COMP_PARAM->fForceMemvars = iValue != 0; else iValue = HB_COMP_PARAM->fForceMemvars ? 1 : 0; break; case 'w': case 'W': if( fSet ) { if( iValue >= 0 && iValue <= 3 ) HB_COMP_PARAM->iWarnings = iValue; else fError = HB_TRUE; } else iValue = HB_COMP_PARAM->iWarnings; break; case 'z': case 'Z': if( fSet ) { if( iValue ) HB_COMP_PARAM->supported &= ~HB_COMPFLAG_SHORTCUTS; else HB_COMP_PARAM->supported |= HB_COMPFLAG_SHORTCUTS; } else iValue = ( HB_COMP_PARAM->supported & HB_COMPFLAG_SHORTCUTS ) ? 0 : 1; break; default: fError = HB_TRUE; } } else if( i == 2 ) { if( szSwitch[ 0 ] == 'k' || szSwitch[ 0 ] == 'K' ) { int iFlag = 0; /* -k? parameters are case sensitive */ switch( szSwitch[ 1 ] ) { case '?': if( fSet ) HB_COMP_PARAM->supported = iValue; else iValue = HB_COMP_PARAM->supported; break; case 'c': case 'C': if( fSet ) { /* clear all flags - minimal set of features */ HB_COMP_PARAM->supported &= HB_COMPFLAG_SHORTCUTS; HB_COMP_PARAM->supported |= HB_COMPFLAG_OPTJUMP | HB_COMPFLAG_MACROTEXT; } else { iValue = ( HB_COMP_PARAM->supported & ~HB_COMPFLAG_SHORTCUTS ) == ( HB_COMPFLAG_OPTJUMP | HB_COMPFLAG_MACROTEXT ) ? 1 : 0; } break; case 'h': case 'H': iFlag = HB_COMPFLAG_HARBOUR; break; case 'o': case 'O': iFlag = HB_COMPFLAG_EXTOPT; break; case 'i': case 'I': iFlag = HB_COMPFLAG_HB_INLINE; break; case 'r': case 'R': iFlag = HB_COMPFLAG_RT_MACRO; break; case 'x': case 'X': iFlag = HB_COMPFLAG_XBASE; break; case 'j': case 'J': iFlag = HB_COMPFLAG_OPTJUMP; iValue = ! iValue; break; case 'm': case 'M': iFlag = HB_COMPFLAG_MACROTEXT; iValue = ! iValue; break; case 'd': case 'D': iFlag = HB_COMPFLAG_MACRODECL; break; case 's': case 'S': iFlag = HB_COMPFLAG_ARRSTR; break; default: fError = HB_TRUE; } if( ! fError && iFlag ) { if( fSet ) { if( iValue ) HB_COMP_PARAM->supported |= iFlag; else HB_COMP_PARAM->supported &= ~iFlag; } else { if( iValue ) iValue = HB_COMP_PARAM->supported & iFlag ? 0 : 1; else iValue = HB_COMP_PARAM->supported & iFlag ? 1 : 0; } } } else if( hb_strnicmp( szSwitch, "es", 2 ) == 0 ) { if( fSet ) { if( iValue == HB_EXITLEVEL_DEFAULT || iValue == HB_EXITLEVEL_SETEXIT || iValue == HB_EXITLEVEL_DELTARGET ) HB_COMP_PARAM->iExitLevel = iValue; } else iValue = HB_COMP_PARAM->iExitLevel; } else if( hb_stricmp( szSwitch, "p+" ) == 0 ) { if( fSet ) HB_COMP_PARAM->fPPT = iValue != 0; else iValue = HB_COMP_PARAM->fPPT ? 1 : 0; } else fError = HB_TRUE; } /* xHarbour extension */ else if( i >= 4 && hb_strnicmp( szSwitch, "TEXTHIDDEN", i ) == 0 ) { if( fSet ) { if( iValue >= 0 && iValue <= 1 ) HB_COMP_PARAM->iHidden = iValue; } else iValue = HB_COMP_PARAM->iHidden; } else fError = HB_TRUE; *piValue = iValue; return fError; }
static HB_BOOL hb_dbQSortIsLess( LPDBQUICKSORT pQuickSort, HB_ULONG ulRecNo1, HB_ULONG ulRecNo2 ) { HB_USHORT uiCount, uiField; DBFAREAP pArea; LPFIELD pField; HB_BOOL bAscending, bIgnoreCase; int iResult; pArea = ( DBFAREAP ) pQuickSort->pSortInfo->dbtri.lpaSource; /* Read records */ hb_fsSeek( pQuickSort->hFile, ( ulRecNo1 - 1 ) * pQuickSort->uiRecordLen, FS_SET ); hb_fsRead( pQuickSort->hFile, pQuickSort->pSwapBufferA, pQuickSort->uiRecordLen ); hb_fsSeek( pQuickSort->hFile, ( ulRecNo2 - 1 ) * pQuickSort->uiRecordLen, FS_SET ); hb_fsRead( pQuickSort->hFile, pQuickSort->pSwapBufferB, pQuickSort->uiRecordLen ); /* Compare fields */ for( uiCount = 0; uiCount < pQuickSort->pSortInfo->uiItemCount; uiCount++ ) { /* Sort flags */ bIgnoreCase = ( ( pQuickSort->pSortInfo->lpdbsItem[ uiCount ].uiFlags & SF_CASE ) == SF_CASE ); bAscending = ( ( pQuickSort->pSortInfo->lpdbsItem[ uiCount ].uiFlags & SF_ASCEND ) == SF_ASCEND ); uiField = pQuickSort->pSortInfo->lpdbsItem[ uiCount ].uiField - 1; pField = pArea->area.lpFields + uiField; if( pField->uiType == HB_IT_MEMO ) continue; if( pField->uiType == HB_IT_LOGICAL ) { if( pQuickSort->pSwapBufferA[ pArea->pFieldOffset[ uiField ] ] == 'T' || pQuickSort->pSwapBufferA[ pArea->pFieldOffset[ uiField ] ] == 't' || pQuickSort->pSwapBufferA[ pArea->pFieldOffset[ uiField ] ] == 'Y' || pQuickSort->pSwapBufferA[ pArea->pFieldOffset[ uiField ] ] == 'y' ) * pQuickSort->pCmpBufferA = '1'; else * pQuickSort->pCmpBufferA = '0'; if( pQuickSort->pSwapBufferB[ pArea->pFieldOffset[ uiField ] ] == 'T' || pQuickSort->pSwapBufferB[ pArea->pFieldOffset[ uiField ] ] == 't' || pQuickSort->pSwapBufferB[ pArea->pFieldOffset[ uiField ] ] == 'Y' || pQuickSort->pSwapBufferB[ pArea->pFieldOffset[ uiField ] ] == 'y' ) * pQuickSort->pCmpBufferB = '1'; else * pQuickSort->pCmpBufferB = '0'; } else { memcpy( pQuickSort->pCmpBufferA, pQuickSort->pSwapBufferA + pArea->pFieldOffset[ uiField ], pField->uiLen ); memcpy( pQuickSort->pCmpBufferB, pQuickSort->pSwapBufferB + pArea->pFieldOffset[ uiField ], pField->uiLen ); } pQuickSort->pCmpBufferA[ pField->uiLen ] = 0; pQuickSort->pCmpBufferB[ pField->uiLen ] = 0; /* Compare buffers */ if( bIgnoreCase ) iResult = hb_stricmp( ( const char * ) pQuickSort->pCmpBufferA, ( const char * ) pQuickSort->pCmpBufferB ); else iResult = strcmp( ( const char * ) pQuickSort->pCmpBufferA, ( const char * ) pQuickSort->pCmpBufferB ); if( iResult == 0 ) continue; else if( bAscending ) return iResult < 0; else return iResult > 0; } return HB_FALSE; }
/* * 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 ); }
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; }
static HB_ERRCODE adsxOrderInfo( ADSXAREAP pArea, HB_USHORT uiIndex, LPDBORDERINFO pOrderInfo ) { PMIXTAG pTag = pArea->pTagCurrent; /* resolve any pending relations */ if( pArea->adsarea.lpdbPendingRel ) SELF_FORCEREL( ( AREAP ) pArea ); /* all others need an index handle */ if( uiIndex != DBOI_ORDERCOUNT ) { if( pOrderInfo->itmOrder ) { if( HB_IS_STRING( pOrderInfo->itmOrder ) ) { pTag = pArea->pTagList; while( pTag ) { if( ! hb_stricmp( hb_itemGetCPtr( pOrderInfo->itmOrder ), pTag->szName ) ) break; pTag = pTag->pNext; } } else if( HB_IS_NUMERIC( pOrderInfo->itmOrder ) ) { UNSIGNED16 usOrder = 0, usSearch = ( UNSIGNED16 ) hb_itemGetNI( pOrderInfo->itmOrder ); AdsGetNumIndexes( pArea->adsarea.hTable, &usOrder ); pTag = usSearch <= usOrder ? NULL : pArea->pTagList; while( pTag ) { if( ++usOrder == usSearch ) break; pTag = pTag->pNext; } } } if( ! pTag ) return SUPER_ORDINFO( ( AREAP ) pArea, uiIndex, pOrderInfo ); } switch( uiIndex ) { case DBOI_CONDITION: hb_itemPutC( pOrderInfo->itmResult, pTag->szForExpr ); break; case DBOI_EXPRESSION: hb_itemPutC( pOrderInfo->itmResult, pTag->szKeyExpr ); break; case DBOI_ISCOND: hb_itemPutL( pOrderInfo->itmResult, pTag->pForItem != NULL ); break; case DBOI_ISDESC: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_UNIQUE: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_KEYTYPE: hb_itemPutCL( pOrderInfo->itmResult, ( char * ) &pTag->bType, 1 ); break; case DBOI_KEYSIZE: hb_itemPutNI( pOrderInfo->itmResult, pTag->uiLen ); break; case DBOI_KEYVAL: { PHB_ITEM pItem; PHB_CODEPAGE pCodepage = hb_cdpSelect( pArea->adsarea.area.cdPage ); pItem = hb_vmEvalBlockOrMacro( pTag->pKeyItem ); hb_cdpSelect( pCodepage ); hb_itemMove( pOrderInfo->itmResult, pItem ); break; } case DBOI_KEYCOUNT: case DBOI_KEYCOUNTRAW: /* ignore filter but RESPECT SCOPE */ hb_itemPutNL( pOrderInfo->itmResult, pTag->ulRecCount ); break; case DBOI_POSITION: case DBOI_RECNO: case DBOI_KEYNORAW: if( uiIndex == DBOI_POSITION && pOrderInfo->itmNewVal && HB_IS_NUMERIC( pOrderInfo->itmNewVal ) ) { HB_ULONG ulPos; ulPos = hb_itemGetNL( pOrderInfo->itmNewVal ); if( ulPos > 0 && ulPos <= pTag->ulRecCount ) SELF_GOTO( ( AREAP ) pArea, pTag->pKeys[ ulPos - 1 ]->rec ); pOrderInfo->itmResult = hb_itemPutL( pOrderInfo->itmResult, ! pArea->adsarea.area.fEof ); } else { PMIXKEY pKey; HB_ULONG ulKeyPos; if( ! pArea->adsarea.fPositioned ) SELF_GOTO( ( AREAP ) pArea, pArea->adsarea.ulRecNo ); else pArea->adsarea.area.fEof = HB_FALSE; pKey = mixKeyEval( pTag, pArea ); hb_itemPutNL( pOrderInfo->itmResult, mixFindKey( pTag, pKey, &ulKeyPos ) ? ( ulKeyPos + 1 ) : 0 ); mixKeyFree( pKey ); } break; case DBOI_RELKEYPOS: if( pOrderInfo->itmNewVal && HB_IS_NUMERIC( pOrderInfo->itmNewVal ) ) { HB_ULONG ulPos; ulPos = ( HB_ULONG ) ( hb_itemGetND( pOrderInfo->itmNewVal ) * ( double ) pTag->ulRecCount ); if( ulPos > 0 && ulPos <= pTag->ulRecCount ) SELF_GOTO( ( AREAP ) pArea, pTag->pKeys[ ulPos - 1 ]->rec ); pOrderInfo->itmResult = hb_itemPutL( pOrderInfo->itmResult, ! pArea->adsarea.area.fEof ); } else { PMIXKEY pKey; HB_ULONG ulKeyPos; if( ! pArea->adsarea.fPositioned ) SELF_GOTO( ( AREAP ) pArea, pArea->adsarea.ulRecNo ); else pArea->adsarea.area.fEof = HB_FALSE; pKey = mixKeyEval( pTag, pArea ); if( ! mixFindKey( pTag, pKey, &ulKeyPos + 1 ) ) ulKeyPos = 0; mixKeyFree( pKey ); pOrderInfo->itmResult = hb_itemPutND( pOrderInfo->itmResult, ( double ) ulKeyPos / ( double ) pTag->ulRecCount ); } break; case DBOI_NAME: hb_itemPutC( pOrderInfo->itmResult, pTag->szName ); break; case DBOI_BAGNAME: hb_itemPutC( pOrderInfo->itmResult, NULL ); break; case DBOI_FULLPATH: hb_itemPutC( pOrderInfo->itmResult, NULL ); break; case DBOI_BAGEXT: hb_itemPutC( pOrderInfo->itmResult, "mix" ); break; case DBOI_ORDERCOUNT: { UNSIGNED16 usOrder = 0; AdsGetNumIndexes( pArea->adsarea.hTable, &usOrder ); pTag = pArea->pTagList; while( pTag ) { pTag = pTag->pNext; usOrder++; } hb_itemPutNI( pOrderInfo->itmResult, ( int ) usOrder ); break; } case DBOI_NUMBER: { PMIXTAG pTag2; UNSIGNED16 usOrder = 0; AdsGetNumIndexes( pArea->adsarea.hTable, &usOrder ); pTag2 = pArea->pTagList; usOrder++; while( pTag2 && pTag != pTag2 ) { pTag2 = pTag2->pNext; usOrder++; } hb_itemPutNI( pOrderInfo->itmResult, ( int ) usOrder ); break; } case DBOI_CUSTOM: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_OPTLEVEL: hb_itemPutNI( pOrderInfo->itmResult, DBOI_OPTIMIZED_NONE ); break; case DBOI_KEYADD: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_KEYDELETE: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; case DBOI_AUTOOPEN: hb_itemPutL( pOrderInfo->itmResult, HB_FALSE ); break; default: return SUPER_ORDINFO( ( AREAP ) pArea, uiIndex, pOrderInfo ); } return HB_SUCCESS; }