c:\harbour\contrib\hbct
addascii.c |
Type | Function | Source | Line |
HB_FUNC | ADDASCII(void)
HB_FUNC( ADDASCII )
{
int iNoRet;
/* suppressing return value ? */
iNoRet = ct_getref() && ISBYREF( 1 );
if( ISCHAR( 1 ) )
{
char *pcSource = hb_parc( 1 );
size_t sLen = hb_parclen( 1 );
char *pcResult;
size_t sPos;
LONG lValue;
int iCarryOver;
if( ISNUM( 3 ) )
sPos = hb_parnl( 3 );
else
sPos = sLen;
if( sPos > sLen || !ISNUM( 2 ) || sLen == 0 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ADDASCII, NULL,
"ADDASCII", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
/* return string unchanged */
if( iNoRet )
hb_retl( 0 );
else
hb_retclen( pcSource, sLen );
return;
}
pcResult = ( char * ) hb_xgrab( sLen + 1 );
hb_xmemcpy( pcResult, pcSource, sLen );
lValue = hb_parnl( 2 );
if( ISLOG( 4 ) )
iCarryOver = hb_parl( 4 );
else
iCarryOver = 0;
if( iCarryOver )
{
size_t sCurrent;
LONG lResult;
for( sCurrent = sPos; sCurrent > 0 && lValue != 0; sCurrent-- )
{
lResult = ( LONG ) pcSource[sCurrent - 1] + ( lValue % 256 );
lValue /= 256;
if( lResult > 255 )
lValue++;
else if( lResult < 0 )
lValue--;
pcResult[sCurrent - 1] = ( char ) ( lResult % 256 );
}
}
else
{
pcResult[sPos - 1] = ( char ) ( ( ( LONG ) pcResult[sPos - 1] + lValue ) % 256 );
}
if( ISBYREF( 1 ) )
hb_storclen( pcResult, sLen, 1 );
if( iNoRet )
{
hb_retl( 0 );
hb_xfree( pcResult );
}
else
hb_retclen_buffer( pcResult, sLen );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ADDASCII,
NULL, "ADDASCII", 0, EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_retl( 0 );
else
hb_retc( NULL );
}
}
| addascii.c | 123 |
asciisum.c |
Type | Function | Source | Line |
HB_FUNC | ASCIISUM(void)
HB_FUNC( ASCIISUM )
{
if( ISCHAR( 1 ) )
{
size_t sStrSize = hb_parclen( 1 );
char *pcString = hb_parc( 1 );
size_t sPos;
ULONG ulResult = 0;
for( sPos = 0; sPos < sStrSize; sPos++ )
ulResult += ( ULONG ) pcString[sPos];
hb_retnl( ulResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_ASCIISUM, NULL, "ASCIISUM", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
{
hb_itemReturnRelease( pSubst );
}
else
{
hb_retni( 0 );
}
}
}
| asciisum.c | 97 |
ascpos.c |
Type | Function | Source | Line |
STATIC VOID | do_ascpos( int iSwitch )
static void do_ascpos( int iSwitch )
{
if( ISCHAR( 1 ) )
{
size_t sStrSize = hb_parclen( 1 );
BYTE *pcString = ( BYTE * ) hb_parc( 1 );
size_t sPos;
if( ISNUM( 2 ) )
sPos = hb_parnl( 2 );
else
sPos = sStrSize;
if( ( sPos == 0 ) || ( sPos > sStrSize ) )
{
hb_retni( 0 );
}
else
{
if( iSwitch == DO_ASCPOS_VALPOS )
{
if( isdigit( ( size_t ) pcString[sPos - 1] ) )
hb_retnl( pcString[sPos - 1] - 48 );
else
hb_retni( 0 );
}
else /* iSwitch == DO_ASCPOS_ASCPOS */
{
hb_retnl( pcString[sPos - 1] );
}
}
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_ASCPOS_VALPOS ?
CT_ERROR_VALPOS : CT_ERROR_ASCPOS, NULL,
HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
{
hb_itemReturnRelease( pSubst );
}
else
{
hb_retni( 0 );
}
}
}
| ascpos.c | 66 |
HB_FUNC | ASCPOS(void)
HB_FUNC( ASCPOS )
{
do_ascpos( DO_ASCPOS_ASCPOS );
}
| ascpos.c | 165 |
HB_FUNC | VALPOS(void)
HB_FUNC( VALPOS )
{
do_ascpos( DO_ASCPOS_VALPOS );
}
| ascpos.c | 213 |
atadjust.c |
Type | Function | Source | Line |
HB_FUNC | ATADJUST(void)
HB_FUNC( ATADJUST )
{
if( ISCHAR( 1 ) && ISCHAR( 2 ) && ISNUM( 3 ) )
{
char *pcStringToMatch = hb_parc( 1 );
size_t sStrToMatchLen = ( size_t ) hb_parclen( 1 );
char *pcString = hb_parc( 2 );
size_t sStrLen = ( size_t ) hb_parclen( 2 );
size_t sAdjustPosition = hb_parnl( 3 );
int iMultiPass = ct_getatmupa();
int iAtLike = ct_getatlike();
char cAtLike = ct_getatlikechar();
size_t sIgnore, sMatchStrLen;
ULONG ulCounter;
char *pc = NULL;
char cFillChar;
char *pcRetStr, *pcCheckFill;
size_t sRetStrLen;
/* eventually ignore some characters */
if( ISNUM( 5 ) )
sIgnore = ( size_t ) hb_parnl( 5 );
else
sIgnore = 0;
if( sIgnore >= sStrLen )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATADJUST, NULL, "ATADJUST", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retclen( pcString, sStrLen );
return;
}
else
{
pcString += sIgnore;
sStrLen -= sIgnore;
}
/* check for wrong adjust position */
if( sAdjustPosition == 0 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATADJUST, NULL, "ATADJUST", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retclen( pcString, sStrLen );
return;
}
else
sAdjustPosition--; /* makes live easier since C indices start at zero ! */
/* nth match or last match ? */
if( ISNUM( 4 ) && ( ulCounter = hb_parnl( 4 ) ) != 0 )
{
/* find the th match */
char *pcSubStr;
size_t sSubStrLen;
ULONG ulMatchCounter = 0;
pcSubStr = pcString;
sSubStrLen = sStrLen;
while( ulMatchCounter < ulCounter )
{
switch ( iAtLike )
{
case CT_SETATLIKE_EXACT:
pc = ct_at_exact_forward( pcSubStr, sSubStrLen, pcStringToMatch,
sStrToMatchLen, &sMatchStrLen );
break;
case CT_SETATLIKE_WILDCARD:
pc = ct_at_wildcard_forward( pcSubStr, sSubStrLen, pcStringToMatch,
sStrToMatchLen, cAtLike, &sMatchStrLen );
break;
default:
pc = NULL;
}
if( pc == NULL )
{
/* no match found; if this happens at this point,
there are no matches, so return */
hb_retclen( pcString, sStrLen );
return;
}
ulMatchCounter++;
if( iMultiPass )
pcSubStr = pc + 1;
else
pcSubStr = pc + sMatchStrLen;
sSubStrLen = sStrLen - ( pcSubStr - pcString );
}
}
else /* ( ISNUM( 4 ) && ( (ulCounter = hb_parnl( 4 ) ) != 0 ) */
{
/* we have to find the last match */
switch ( iAtLike )
{
case CT_SETATLIKE_EXACT:
pc = ct_at_exact_backward( pcString, sStrLen, pcStringToMatch,
sStrToMatchLen, &sMatchStrLen );
break;
case CT_SETATLIKE_WILDCARD:
pc = ct_at_wildcard_backward( pcString, sStrLen, pcStringToMatch,
sStrToMatchLen, cAtLike, &sMatchStrLen );
break;
default:
pc = NULL;
}
if( pc == NULL )
{
/* no matches found */
hb_retclen( pcString, sStrLen );
return;
}
}
/* adjust string */
if( ISCHAR( 6 ) )
{
if( hb_parclen( 6 ) > 0 )
cFillChar = *( hb_parc( 6 ) );
else
cFillChar = 0x20;
}
else if( ISNUM( 6 ) )
cFillChar = ( char ) ( hb_parnl( 6 ) % 256 );
else
cFillChar = 0x20;
/* position of pc == adjust position ? */
if( pc == pcString + sAdjustPosition )
{
/* do nothing */
hb_retclen( pcString, sStrLen );
}
else
{
if( pc > pcString + sAdjustPosition )
{
/* adjust to left */
/* check if we only delete cFillChar characters */
for( pcCheckFill = pcString + sAdjustPosition; pcCheckFill < pc; pcCheckFill++ )
if( *pcCheckFill != cFillChar )
{
/* no -> return string unchanged */
hb_retclen( pcString, sStrLen );
return;
}
/* ok -> calculate new string size */
sRetStrLen = sStrLen - ( pc - ( pcString + sAdjustPosition ) );
pcRetStr = ( char * ) hb_xgrab( sRetStrLen + 1 );
/* copy first portion of string */
if( sAdjustPosition > 0 )
hb_xmemcpy( pcRetStr, pcString, sAdjustPosition );
/* copy second portion of string */
if( sRetStrLen > sAdjustPosition )
hb_xmemcpy( pcRetStr + sAdjustPosition, pc, sRetStrLen - sAdjustPosition );
hb_retclen_buffer( pcRetStr, sRetStrLen );
}
else
{
/* adjust to right */
sRetStrLen = sStrLen + ( pcString + sAdjustPosition ) - pc;
pcRetStr = ( char * ) hb_xgrab( sRetStrLen + 1 );
/* copy first portion of string */
if( pc > pcString )
hb_xmemcpy( pcRetStr, pcString, pc - pcString );
/* fill characters */
hb_xmemset( pcRetStr + ( pc - pcString ), cFillChar,
sAdjustPosition - ( pc - pcString ) );
/* copy second portion of string */
if( sRetStrLen > sAdjustPosition )
hb_xmemcpy( pcRetStr + sAdjustPosition, pc, sRetStrLen - sAdjustPosition );
hb_retclen_buffer( pcRetStr, sRetStrLen );
}
}
}
else /* ((ISCHAR (1)) && (ISCHAR (2)) && (ISNUM (3))) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_ATADJUST, NULL, "ATADJUST", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( ISCHAR( 2 ) )
hb_retclen( hb_parc( 2 ), hb_parclen( 2 ) );
else
hb_retc( NULL );
}
}
| atadjust.c | 101 |
atnum.c |
Type | Function | Source | Line |
STATIC VOID | do_atnum( int iSwitch )
static void do_atnum( int iSwitch )
{
if( ISCHAR( 1 ) && ISCHAR( 2 ) )
{
char *pcStringToMatch = hb_parc( 1 );
size_t sStrToMatchLen = ( size_t ) hb_parclen( 1 );
char *pcString = hb_parc( 2 );
size_t sStrLen = ( size_t ) hb_parclen( 2 );
int iMultiPass = ct_getatmupa();
int iAtLike = ct_getatlike();
char cAtLike = ct_getatlikechar();
size_t sIgnore, sMatchStrLen;
ULONG ulCounter;
char *pc = NULL;
/* eventually ignore some characters */
if( ISNUM( 4 ) )
sIgnore = ( size_t ) hb_parnl( 4 );
else
sIgnore = 0;
if( sIgnore >= sStrLen )
{
switch ( iSwitch )
{
case DO_ATNUM_AFTERATNUM:
{
/* AFTERATNUM */
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_AFTERATNUM, NULL,
"AFTERATNUM", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
break;
}
case DO_ATNUM_BEFORATNUM:
{
/* BEFORATNUM */
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_BEFORATNUM, NULL,
"BEFORATNUM", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
break;
}
case DO_ATNUM_ATNUM:
{
/* ATNUM */
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATNUM, NULL, "ATNUM", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( 0 );
break;
}
}
return;
}
else
{
pcString += sIgnore;
sStrLen -= sIgnore;
}
/* nth match or last match ? */
if( ISNUM( 3 ) && ( ulCounter = hb_parnl( 3 ) ) != 0 )
{
/* find the th match */
char *pcSubStr;
size_t sSubStrLen;
ULONG ulMatchCounter = 0;
pcSubStr = pcString;
sSubStrLen = sStrLen;
while( ulMatchCounter < ulCounter )
{
switch ( iAtLike )
{
case CT_SETATLIKE_EXACT:
pc = ct_at_exact_forward( pcSubStr, sSubStrLen, pcStringToMatch,
sStrToMatchLen, &sMatchStrLen );
break;
case CT_SETATLIKE_WILDCARD:
pc = ct_at_wildcard_forward( pcSubStr, sSubStrLen, pcStringToMatch,
sStrToMatchLen, cAtLike, &sMatchStrLen );
break;
default:
pc = NULL;
}
if( pc == NULL )
{
/* no match found; if this happens at this point,
there are no matches, so return an empty string */
switch ( iSwitch )
{
case DO_ATNUM_AFTERATNUM:
case DO_ATNUM_BEFORATNUM:
/* AFTERATNUM */
/* BEFORATNUM */
hb_retc( NULL );
break;
case DO_ATNUM_ATNUM:
/* ATNUM */
hb_retni( 0 );
break;
}
return;
}
ulMatchCounter++;
if( iMultiPass )
pcSubStr = pc + 1;
else
pcSubStr = pc + sMatchStrLen;
sSubStrLen = sStrLen - ( pcSubStr - pcString );
}
}
else /* ( ISNUM( 3 ) && ( ulCounter = hb_parnl( 3 ) ) != 0 ) */
{
/* we have to find the last match and return the
string after that last match */
switch ( iAtLike )
{
case CT_SETATLIKE_EXACT:
pc = ct_at_exact_backward( pcString, sStrLen, pcStringToMatch,
sStrToMatchLen, &sMatchStrLen );
break;
case CT_SETATLIKE_WILDCARD:
pc = ct_at_wildcard_backward( pcString, sStrLen, pcStringToMatch,
sStrToMatchLen, cAtLike, &sMatchStrLen );
break;
default:
pc = NULL;
}
if( pc == NULL )
{
/* no matches found */
switch ( iSwitch )
{
case DO_ATNUM_AFTERATNUM:
case DO_ATNUM_BEFORATNUM:
/* AFTERATNUM */
/* BEFORATNUM */
hb_retc( NULL );
break;
case DO_ATNUM_ATNUM:
/* ATNUM */
hb_retni( 0 );
break;
}
return;
}
}
switch ( iSwitch )
{
case DO_ATNUM_AFTERATNUM:
/* AFTERATNUM */
if( pc + sMatchStrLen >= pcString + sStrLen )
hb_retc( NULL );
else
hb_retclen( pc + sMatchStrLen, sStrLen - ( pc + sMatchStrLen - pcString ) );
break;
case DO_ATNUM_BEFORATNUM:
/* BEFORATNUM */
hb_retclen( pcString - sIgnore, pc - ( pcString - sIgnore ) );
break;
case DO_ATNUM_ATNUM:
/* ATNUM */
hb_retnl( pc - ( pcString - sIgnore ) + 1 );
break;
}
}
else /* ((ISCHAR (1)) && (ISCHAR (2))) */
{
switch ( iSwitch )
{
case DO_ATNUM_AFTERATNUM:
case DO_ATNUM_BEFORATNUM:
{
/* AFTERATNUM */
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch ==
DO_ATNUM_AFTERATNUM ? CT_ERROR_AFTERATNUM :
CT_ERROR_BEFORATNUM, NULL, HB_ERR_FUNCNAME, 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
break;
}
case DO_ATNUM_ATNUM:
{
/* ATNUM */
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATNUM,
NULL, "ATNUM", 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
break;
}
}
}
}
| atnum.c | 65 |
HB_FUNC | AFTERATNUM(void)
HB_FUNC( AFTERATNUM )
{
do_atnum( DO_ATNUM_AFTERATNUM );
}
| atnum.c | 364 |
HB_FUNC | BEFORATNUM(void)
HB_FUNC( BEFORATNUM )
{
do_atnum( DO_ATNUM_BEFORATNUM );
}
| atnum.c | 426 |
HB_FUNC | ATNUM(void)
HB_FUNC( ATNUM )
{
do_atnum( DO_ATNUM_ATNUM );
}
| atnum.c | 487 |
atrepl.c |
Type | Function | Source | Line |
HB_FUNC | ATREPL(void)
HB_FUNC( ATREPL )
{
if( ISCHAR( 1 ) && ISCHAR( 2 ) )
{
char *pcStringToMatch = hb_parc( 1 );
size_t sStrToMatchLen = ( size_t ) hb_parclen( 1 );
char *pcString = hb_parc( 2 );
size_t sStrLen = ( size_t ) hb_parclen( 2 );
int iMultiPass = ct_getatmupa();
int iAtLike = ct_getatlike();
char cAtLike = ct_getatlikechar();
size_t sIgnore, sMatchStrLen;
ULONG ulCounter;
char *pc;
char *pcReplacement;
size_t sReplaceLen;
int iReplaceMode;
char *pcRetStr;
size_t sRetStrLen;
/* eventually ignore some characters */
if( ISNUM( 6 ) )
sIgnore = ( size_t ) hb_parnl( 6 );
else
sIgnore = 0;
if( sIgnore >= sStrLen )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_ATREPL, NULL,
"ATREPL", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retclen( pcString, sStrLen );
return;
}
/* replacement */
if( ISCHAR( 3 ) )
{
pcReplacement = hb_parc( 3 );
sReplaceLen = hb_parclen( 3 );
}
else
{
pcReplacement = "";
sReplaceLen = 0;
}
/* replace mode */
if( ISLOG( 5 ) )
iReplaceMode = hb_parl( 5 );
else
iReplaceMode = 0;
/* nth match or last match ? */
if( ISNUM( 4 ) )
ulCounter = hb_parnl( 4 );
else
ulCounter = 0;
/* little trick: */
if( iReplaceMode == 0 && ulCounter == 0 )
ulCounter = ULONG_MAX;
if( ulCounter != 0 )
{
/* depending on iReplaceMode: replace all occurences including the nth one
or only the nth occurence
NOTE: if iReplaceMode = false and the nth occurence does not exist,
all occurences are replaced */
char *pcRetSubStr;
size_t sRetSubStrLen;
ULONG ulMatchCounter = 0;
sRetStrLen = sStrLen;
pcRetStr = ( char * ) hb_xgrab( sRetStrLen );
hb_xmemcpy( pcRetStr, pcString, sRetStrLen );
pcRetSubStr = pcRetStr + sIgnore;
sRetSubStrLen = sRetStrLen - sIgnore;
while( ulMatchCounter < ulCounter )
{
switch ( iAtLike )
{
case CT_SETATLIKE_EXACT:
pc = ct_at_exact_forward( pcRetSubStr, sRetSubStrLen, pcStringToMatch,
sStrToMatchLen, &sMatchStrLen );
break;
case CT_SETATLIKE_WILDCARD:
pc = ct_at_wildcard_forward( pcRetSubStr, sRetSubStrLen, pcStringToMatch,
sStrToMatchLen, cAtLike, &sMatchStrLen );
break;
default:
pc = NULL;
}
if( pc == NULL )
{
hb_retclen( pcRetStr, sRetStrLen );
hb_xfree( pcRetStr );
return;
}
ulMatchCounter++;
/* replace match ? */
if( ( iReplaceMode == 0 ) || ( ulMatchCounter == ulCounter ) )
{
if( sMatchStrLen < sReplaceLen )
{
/* pcRetStr grows, so realloc memory */
/* save pc pointer */
size_t sPCPos = pc - pcRetStr;
pcRetStr = ( char * ) hb_xrealloc( pcRetStr,
sRetStrLen + ( sReplaceLen - sMatchStrLen ) );
pc = pcRetStr + sPCPos;
}
if( sReplaceLen != sMatchStrLen )
memmove( pc + sReplaceLen, pc + sMatchStrLen,
sRetStrLen - ( ( pc + sMatchStrLen ) - pcRetStr ) );
if( sReplaceLen > 0 )
hb_xmemcpy( pc, pcReplacement, sReplaceLen );
if( iMultiPass )
pcRetSubStr = pc + 1;
else
pcRetSubStr = pc + sReplaceLen;
sRetStrLen += sReplaceLen - sMatchStrLen;
}
else
{
if( iMultiPass )
pcRetSubStr = pc + 1;
else
pcRetSubStr = pc + sMatchStrLen;
}
sRetSubStrLen = sRetStrLen - ( pcRetSubStr - pcRetStr );
}
}
else /* ( ulCounter != 0 ) */
{
/* find and replace last match */
sRetStrLen = sStrLen;
pcRetStr = ( char * ) hb_xgrab( sRetStrLen );
hb_xmemcpy( pcRetStr, pcString, sRetStrLen );
/* we have to find the last match and replace it */
switch ( iAtLike )
{
case CT_SETATLIKE_EXACT:
pc = ct_at_exact_backward( pcRetStr + sIgnore, sRetStrLen - sIgnore,
pcStringToMatch, sStrToMatchLen, &sMatchStrLen );
break;
case CT_SETATLIKE_WILDCARD:
pc = ct_at_wildcard_backward( pcRetStr + sIgnore, sRetStrLen - sIgnore,
pcStringToMatch, sStrToMatchLen,
cAtLike, &sMatchStrLen );
break;
default:
pc = NULL;
}
if( pc == NULL )
{
hb_retclen( pcRetStr, sRetStrLen );
hb_xfree( pcRetStr );
return;
}
/* replace match */
if( sMatchStrLen < sReplaceLen )
{
/* pcRetStr grows, so realloc memory */
/* save pc pointer */
size_t sPCPos = pc - pcRetStr;
pcRetStr = ( char * ) hb_xrealloc( pcRetStr,
sRetStrLen + ( sReplaceLen - sMatchStrLen ) );
pc = pcRetStr + sPCPos;
}
if( sReplaceLen != sMatchStrLen )
memmove( pc + sReplaceLen, pc + sMatchStrLen,
sRetStrLen - ( ( pc + sMatchStrLen ) - pcRetStr ) );
if( sReplaceLen > 0 )
hb_xmemcpy( pc, pcReplacement, sReplaceLen );
sRetStrLen += ( sReplaceLen - sMatchStrLen );
}
hb_retclen( pcRetStr, sRetStrLen );
hb_xfree( pcRetStr );
}
else /* ( ISCHAR( 1 ) && ISCHAR( 2 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_ATREPL, NULL, "ATREPL", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retclen( hb_parc( 2 ), hb_parclen( 2 ) );
}
}
| atrepl.c | 124 |
bitnum.c |
Type | Function | Source | Line |
STATIC BOOL | __numParam( int iParam, HB_LONG * plNum )
static BOOL __numParam( int iParam, HB_LONG * plNum )
{
char *szHex = hb_parc( iParam );
if( szHex )
{
*plNum = 0;
while( *szHex == ' ' )
szHex++;
while( *szHex )
{
char c = *szHex++;
if( c >= '0' && c <= '9' )
c -= '0';
else if( c >= 'A' && c <= 'F' )
c -= 'A' - 10;
else if( c >= 'a' && c <= 'f' )
c -= 'a' - 10;
else
break;
*plNum = ( *plNum << 4 ) | c;
iParam = 0;
}
if( !iParam )
return TRUE;
}
else if( ISNUM( iParam ) )
{
*plNum = hb_parnint( iParam );
return TRUE;
}
*plNum = -1;
return FALSE;
}
| bitnum.c | 59 |
HB_FUNC | NUMAND(void)
HB_FUNC( NUMAND )
{
int iPCount = hb_pcount(), i = 1;
HB_LONG lValue = -1, lNext = 0;
if( iPCount && __numParam( 1, &lValue ) )
{
while( --iPCount && __numParam( ++i, &lNext ) )
lValue &= lNext;
if( iPCount )
lValue = -1;
}
hb_retnint( lValue );
}
| bitnum.c | 96 |
HB_FUNC | NUMOR(void)
HB_FUNC( NUMOR )
{
int iPCount = hb_pcount(), i = 1;
HB_LONG lValue = -1, lNext = 0;
if( iPCount && __numParam( 1, &lValue ) )
{
while( --iPCount && __numParam( ++i, &lNext ) )
lValue |= lNext;
if( iPCount )
lValue = -1;
}
hb_retnint( lValue );
}
| bitnum.c | 112 |
HB_FUNC | NUMXOR(void)
HB_FUNC( NUMXOR )
{
int iPCount = hb_pcount(), i = 1;
HB_LONG lValue = -1, lNext = 0;
if( iPCount && __numParam( 1, &lValue ) )
{
while( --iPCount && __numParam( ++i, &lNext ) )
lValue ^= lNext;
if( iPCount )
lValue = -1;
}
hb_retnint( lValue );
}
| bitnum.c | 128 |
HB_FUNC | NUMNOT(void)
HB_FUNC( NUMNOT )
{
HB_LONG lValue;
if( __numParam( 1, &lValue ) )
lValue = ( ~lValue ) & 0xffff;
hb_retnint( lValue );
}
| bitnum.c | 144 |
HB_FUNC | NUMLOW(void)
HB_FUNC( NUMLOW )
{
HB_LONG lValue;
if( __numParam( 1, &lValue ) )
lValue &= 0xff;
hb_retnint( lValue );
}
| bitnum.c | 154 |
HB_FUNC | NUMHIGH(void)
HB_FUNC( NUMHIGH )
{
HB_LONG lValue;
if( __numParam( 1, &lValue ) /* && lValue == lValue & 0xffff */ )
lValue = ( lValue >> 8 ) & 0xff;
hb_retnint( lValue );
}
| bitnum.c | 164 |
HB_FUNC | NUMROL(void)
HB_FUNC( NUMROL )
{
HB_LONG lValue, lShift;
if( __numParam( 1, &lValue ) && lValue == ( lValue & 0xffff ) && __numParam( 2, &lShift )
&& lShift == ( lShift & 0xffff ) )
{
if( ISLOG( 3 ) && hb_parl( 3 ) )
{
USHORT us = ( USHORT ) ( lValue & 0xff ) << ( lShift & 0x07 );
lValue = ( lValue & 0xff00 ) | ( us & 0xff ) | ( us >> 8 );
}
else
{
lValue <<= ( lShift & 0x0f );
lValue = ( lValue & 0xffff ) | ( lValue >> 16 );
}
}
else
lValue = -1;
hb_retnint( lValue );
}
| bitnum.c | 174 |
HB_FUNC | NUMMIRR(void)
HB_FUNC( NUMMIRR )
{
HB_LONG lValue;
if( __numParam( 1, &lValue ) && lValue == ( lValue & 0xffff ) )
{
USHORT usBits = ISLOG( 2 ) && hb_parl( 2 ) ? 8 : 16;
USHORT usResult = ( USHORT ) ( lValue >> usBits );
do
{
usResult <<= 1;
if( lValue && 1 )
usResult |= 1;
lValue >>= 1;
}
while( --usBits );
lValue = usResult;
}
else
lValue = -1;
hb_retnint( lValue );
}
| bitnum.c | 200 |
HB_FUNC | CLEARBIT(void)
HB_FUNC( CLEARBIT )
{
int iPCount = hb_pcount(), iBit, i = 1;
HB_LONG lValue;
if( __numParam( 1, &lValue ) )
{
while( --iPCount )
{
iBit = hb_parni( ++i );
if( iBit < 1 || iBit > 64 )
break;
lValue &= ~( ( ( HB_LONG ) 1 ) << ( iBit - 1 ) );
}
if( iPCount )
lValue = -1;
}
hb_retnint( lValue );
}
| bitnum.c | 226 |
HB_FUNC | SETBIT(void)
HB_FUNC( SETBIT )
{
int iPCount = hb_pcount(), iBit, i = 1;
HB_LONG lValue;
if( __numParam( 1, &lValue ) )
{
while( --iPCount )
{
iBit = hb_parni( ++i );
if( iBit < 1 || iBit > 64 )
break;
lValue |= ( ( HB_LONG ) 1 ) << ( iBit - 1 );
}
if( iPCount )
lValue = -1;
}
hb_retnint( lValue );
}
| bitnum.c | 248 |
HB_FUNC | ISBIT(void)
HB_FUNC( ISBIT )
{
HB_LONG lValue;
if( __numParam( 1, &lValue ) )
{
int iBit = hb_parni( 2 );
if( iBit )
--iBit;
lValue &= ( ( HB_LONG ) 1 ) << iBit;
}
else
lValue = 0;
hb_retl( lValue != 0 );
}
| bitnum.c | 270 |
HB_FUNC | INTNEG(void)
HB_FUNC( INTNEG )
{
HB_LONG lValue;
if( __numParam( 1, &lValue ) )
{
BOOL f32Bit = ISLOG( 2 ) && hb_parl( 2 );
if( f32Bit )
hb_retnint( ( INT16 ) lValue );
else
hb_retnint( ( INT32 ) lValue );
}
else
hb_retni( 0 );
}
| bitnum.c | 288 |
HB_FUNC | INTPOS(void)
HB_FUNC( INTPOS )
{
HB_LONG lValue;
if( __numParam( 1, &lValue ) )
{
BOOL f32Bit = ISLOG( 2 ) && hb_parl( 2 );
if( f32Bit )
hb_retnint( ( UINT16 ) lValue );
else
#ifndef HB_LONG_LONG_OFF
hb_retnint( ( UINT32 ) lValue );
#else
hb_retnlen( ( UINT32 ) lValue, 0, 0 );
#endif
}
else
hb_retni( 0 );
}
| bitnum.c | 305 |
charevod.c |
Type | Function | Source | Line |
STATIC VOID | do_charevod( int iSwitch )
static void do_charevod( int iSwitch )
{
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sLen = hb_parclen( 1 );
char *pcResult;
size_t sPos, sResultPos;
if( sLen == 0 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_CHAREVOD_CHAREVEN ?
CT_ERROR_CHAREVEN : CT_ERROR_CHARODD,
NULL, HB_ERR_FUNCNAME, 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
return;
}
pcResult = ( char * ) hb_xgrab( ( sLen + 1 ) / 2 );
if( iSwitch == DO_CHAREVOD_CHAREVEN )
sPos = 1;
else
sPos = 0;
sResultPos = 0;
for( ; sPos < sLen; sPos += 2 )
pcResult[sResultPos++] = pcString[sPos];
if( sResultPos == 0 )
hb_retc( NULL );
else
hb_retclen( pcResult, sResultPos );
hb_xfree( pcResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_CHAREVOD_CHAREVEN ?
CT_ERROR_CHAREVEN : CT_ERROR_CHARODD, NULL,
HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| charevod.c | 65 |
HB_FUNC | CHAREVEN(void)
HB_FUNC( CHAREVEN )
{
do_charevod( DO_CHAREVOD_CHAREVEN );
}
| charevod.c | 167 |
HB_FUNC | CHARODD(void)
HB_FUNC( CHARODD )
{
do_charevod( DO_CHAREVOD_CHARODD );
}
| charevod.c | 208 |
charlist.c |
Type | Function | Source | Line |
STATIC VOID | do_list( int iSwitch )
static void do_list( int iSwitch )
{
char *pcString;
size_t sStrLen;
size_t asCharCnt[256];
size_t sCnt;
/* init asCharCnt */
for( sCnt = 0; sCnt < 256; sCnt++ )
{
asCharCnt[sCnt] = 0;
}
/* init params */
if( ISCHAR( 1 ) )
{
pcString = hb_parc( 1 );
sStrLen = ( size_t ) hb_parclen( 1 );
}
else
{
pcString = "";
sStrLen = 0;
}
/* count characters */
if( iSwitch == DO_LIST_CHARLIST )
{
char pcRet[256];
size_t sRetStrLen = 0;
for( sCnt = 0; sCnt < sStrLen; sCnt++ )
{
if( asCharCnt[( size_t ) ( pcString[sCnt] )] == 0 )
{
pcRet[sRetStrLen++] = pcString[sCnt];
asCharCnt[( size_t ) ( pcString[sCnt] )] = 1;
}
}
hb_retclen( pcRet, sRetStrLen );
}
else
{
for( sCnt = 0; sCnt < sStrLen; sCnt++ )
{
size_t sIndex = ( size_t ) ( unsigned char ) ( *( pcString + sCnt ) );
asCharCnt[sIndex] = asCharCnt[sIndex] + 1;
}
switch ( iSwitch )
{
case DO_LIST_CHARSLIST:
{
char *pcRet;
size_t sRetStrLen = 0;
pcRet = ( char * ) hb_xgrab( 256 );
for( sCnt = 0; sCnt < 256; sCnt++ )
{
if( asCharCnt[sCnt] != 0 )
pcRet[ sRetStrLen++ ] = ( unsigned char ) sCnt;
}
hb_retclen( pcRet, sRetStrLen );
hb_xfree( pcRet );
break;
}
case DO_LIST_CHARNOLIST:
{
char *pcRet;
size_t sRetStrLen = 0;
pcRet = ( char * ) hb_xgrab( 256 );
for( sCnt = 0; sCnt < 256; sCnt++ )
{
if( asCharCnt[sCnt] == 0 )
{
*( pcRet + sRetStrLen ) = ( unsigned char ) sCnt;
sRetStrLen++;
}
}
hb_retclen( pcRet, sRetStrLen );
hb_xfree( pcRet );
break;
}
case DO_LIST_CHARHIST:
{
PHB_ITEM pArray = hb_itemArrayNew( 256 );
for( sCnt = 0; sCnt < 256; sCnt++ )
hb_arraySetNL( pArray, sCnt + 1, asCharCnt[sCnt] );
hb_itemReturnRelease( pArray );
break;
}
}
}
}
| charlist.c | 67 |
HB_FUNC | CHARLIST(void)
HB_FUNC( CHARLIST )
{
do_list( DO_LIST_CHARLIST );
}
| charlist.c | 210 |
HB_FUNC | CHARSLIST(void)
HB_FUNC( CHARSLIST )
{
do_list( DO_LIST_CHARSLIST );
}
| charlist.c | 255 |
HB_FUNC | CHARNOLIST(void)
HB_FUNC( CHARNOLIST )
{
do_list( DO_LIST_CHARNOLIST );
}
| charlist.c | 299 |
HB_FUNC | CHARHIST(void)
HB_FUNC( CHARHIST )
{
do_list( DO_LIST_CHARHIST );
}
| charlist.c | 344 |
charmirr.c |
Type | Function | Source | Line |
HB_FUNC | CHARMIRR(void)
HB_FUNC( CHARMIRR )
{
int iNoRet;
/* suppressing return value ? */
iNoRet = ct_getref() && ISBYREF( 1 );
/* param check */
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcRet, *pc1, *pc2;
int iDontMirrorSpaces;
if( ISLOG( 2 ) )
iDontMirrorSpaces = hb_parl( 2 );
else
iDontMirrorSpaces = 0;
if( sStrLen == 0 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARMIRR, NULL,
"CHARMIRR", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
if( iNoRet )
hb_retl( 0 );
else
hb_retc( NULL );
return;
}
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
pc1 = pcString + sStrLen - 1;
if( iDontMirrorSpaces )
{
pc2 = pcRet + sStrLen - 1;
while( ( pc1 >= pcString ) && ( *pc1 == 0x20 ) )
{
*pc2 = 0x20;
pc1--;
pc2--;
}
}
pc2 = pcRet;
for( ; pc1 >= pcString; pc1-- )
{
*pc2 = *pc1;
pc2++;
}
/* return string */
if( ISBYREF( 1 ) )
hb_storclen( pcRet, sStrLen, 1 );
if( iNoRet )
{
hb_retl( 0 );
hb_xfree( pcRet );
}
else
hb_retclen_buffer( pcRet, sStrLen );
}
else /* if( ISCHAR( 1 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CHARMIRR, NULL, "CHARMIRR", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_retl( 0 );
else
hb_retc( NULL );
}
}
| charmirr.c | 104 |
charmix.c |
Type | Function | Source | Line |
HB_FUNC | CHARMIX(void)
HB_FUNC( CHARMIX )
{
if( ISCHAR( 1 ) )
{
char *pcString1 = hb_parc( 1 );
char *pcString2, *pcResult;
size_t sLen1 = hb_parclen( 1 );
size_t sLen2, sPos1, sPos2, sResultPos;
if( sLen1 == 0 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARMIX, NULL, "CHARMIX", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
return;
}
if( ISCHAR( 2 ) )
{
pcString2 = hb_parc( 2 );
sLen2 = hb_parclen( 2 );
if( sLen2 == 0 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARMIX,
NULL, "CHARMIX", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retclen( pcString1, sLen1 );
return;
}
}
else
{
pcString2 = " "; /* NOTE: The original CT3 uses " " as 2nd string
if the 2nd param is not a string ! */
sLen2 = 1;
}
pcResult = ( char * ) hb_xgrab( sLen1 * 2 + 1 );
sPos2 = sResultPos = 0;
for( sPos1 = 0; sPos1 < sLen1; )
{
pcResult[sResultPos++] = pcString1[sPos1++];
pcResult[sResultPos++] = pcString2[sPos2++];
sPos2 %= sLen2;
}
hb_retclen_buffer( pcResult, sLen1 * 2 );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CHARMIX, NULL, "CHARMIX", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| charmix.c | 111 |
charone.c |
Type | Function | Source | Line |
STATIC VOID | do_charone( int iSwitch )
static void do_charone( int iSwitch )
{
char *pcString;
size_t sStrLen;
char *pcDeleteSet;
size_t sDeleteSetLen;
/* param check */
if( ISCHAR( 1 ) )
{
if( ISCHAR( 2 ) )
{
pcString = hb_parc( 2 );
sStrLen = ( size_t ) hb_parclen( 2 );
pcDeleteSet = hb_parc( 1 );
sDeleteSetLen = ( size_t ) hb_parclen( 1 );
}
else
{
pcString = hb_parc( 1 );
sStrLen = ( size_t ) hb_parclen( 1 );
pcDeleteSet = NULL;
sDeleteSetLen = 0;
}
switch ( iSwitch )
{
case DO_CHARONE_CHARONE:
if( sStrLen > 1 )
{
char *pcSub;
char *pcRet;
size_t sRetStrLen = 0;
char cCurrent = *pcString;
pcRet = ( char * ) hb_xgrab( sStrLen );
/* copy first char */
pcRet[sRetStrLen++] = cCurrent;
for( pcSub = pcString + 1; pcSub < pcString + sStrLen; pcSub++ )
{
if( *pcSub != cCurrent )
{
cCurrent = *pcSub;
pcRet[sRetStrLen++] = cCurrent;
}
else if( pcDeleteSet != NULL &&
!ct_at_exact_forward( pcDeleteSet, sDeleteSetLen,
pcSub, 1, NULL ) )
{
pcRet[sRetStrLen++] = cCurrent;
}
}
hb_retclen( pcRet, sRetStrLen );
hb_xfree( pcRet );
}
else /* if( sStrLen > 1 ) */
{
/* algorithm does nothing to 1-char-strings */
hb_retclen( pcString, sStrLen );
}
break;
case DO_CHARONE_WORDONE:
if( sStrLen > 3 && sDeleteSetLen >= 2 )
{
char *pcSub;
char *pcRet;
size_t sRetStrLen = 0;
char cCurrent1 = pcString[0];
char cCurrent2 = pcString[1];
pcRet = ( char * ) hb_xgrab( sStrLen );
/* copy first double char */
pcRet[sRetStrLen++] = cCurrent1;
pcRet[sRetStrLen++] = cCurrent2;
for( pcSub = pcString + 2; pcSub < pcString + sStrLen - 1; pcSub += 2 )
{
if( !( pcSub[0] == cCurrent1 && pcSub[1] == cCurrent2 ) )
{
cCurrent1 = pcSub[0];
cCurrent2 = pcSub[1];
pcRet[sRetStrLen++] = cCurrent1;
pcRet[sRetStrLen++] = cCurrent2;
}
else if( pcDeleteSet != NULL )
{
char *pc = NULL;
char *pStart = pcDeleteSet;
size_t sLen = sDeleteSetLen;
while( sLen >= 2 &&
( pc = ct_at_exact_forward( pStart, sLen, pcSub,
2, NULL ) ) != 0 &&
( pc - pcDeleteSet ) % 2 == 1 )
{
pStart = pc + 1;
sLen = sDeleteSetLen - ( pStart - pcDeleteSet );
}
if( pc == NULL )
{
pcRet[sRetStrLen++] = cCurrent1;
pcRet[sRetStrLen++] = cCurrent2;
}
}
}
/* copy last character if string len is odd */
if( sStrLen & 1 )
{
pcRet[sRetStrLen++] = pcString[sStrLen - 1];
}
hb_retclen( pcRet, sRetStrLen );
hb_xfree( pcRet );
}
else /* if( sStrLen > 3 ) */
{
/* algorithm does nothing to 3-char-strings */
hb_retclen( pcString, sStrLen );
}
break;
} /* switch( iSwitch ) */
}
else /* if( ISCHAR( 1 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_CHARONE_CHARONE ?
CT_ERROR_CHARONE : CT_ERROR_WORDONE,
NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| charone.c | 65 |
HB_FUNC | CHARONE(void)
HB_FUNC( CHARONE )
{
do_charone( DO_CHARONE_CHARONE );
}
| charone.c | 252 |
HB_FUNC | WORDONE(void)
HB_FUNC( WORDONE )
{
do_charone( DO_CHARONE_WORDONE );
}
| charone.c | 299 |
charonly.c |
Type | Function | Source | Line |
STATIC VOID | do_charonly( int iSwitch )
static void do_charonly( int iSwitch )
{
/* param check */
if( ISCHAR( 1 ) && ISCHAR( 2 ) )
{
char *pcString = hb_parc( 2 );
size_t sStrLen = ( size_t ) hb_parclen( 2 );
char *pcOnlySet = hb_parc( 1 );
size_t sOnlySetLen = ( size_t ) hb_parclen( 1 );
char *pcRet;
size_t sRetStrLen = 0;
int iShift, iBool;
char *pcSub, *pc;
/* check for zero-length strings */
switch ( iSwitch )
{
case DO_CHARONLY_CHARONLY:
case DO_CHARONLY_WORDONLY:
if( ( sStrLen == 0 ) || ( sOnlySetLen == 0 ) )
{
hb_retc( NULL );
return;
}
break;
case DO_CHARONLY_CHARREM:
case DO_CHARONLY_WORDREM:
if( sStrLen == 0 )
{
hb_retc( NULL );
return;
}
if( sOnlySetLen == 0 )
{
hb_retclen( pcString, sStrLen );
return;
}
break;
}
if( iSwitch == DO_CHARONLY_WORDONLY ||
iSwitch == DO_CHARONLY_WORDREM )
iShift = 2;
else
iShift = 1;
pcRet = ( char * ) hb_xgrab( sStrLen );
for( pcSub = pcString; pcSub < pcString + sStrLen + 1 - iShift; pcSub += iShift )
{
pc = ct_at_exact_forward( pcOnlySet, sOnlySetLen, pcSub, iShift, NULL );
iBool = ( ( pc != NULL ) && ( ( ( pc - pcOnlySet ) % iShift ) == 0 ) );
if( iBool ? ( iSwitch == DO_CHARONLY_CHARONLY ||
iSwitch == DO_CHARONLY_WORDONLY )
: ( iSwitch == DO_CHARONLY_CHARREM ||
iSwitch == DO_CHARONLY_WORDREM ) )
{
for( pc = pcSub; pc < pcSub + iShift; pc++ )
pcRet[sRetStrLen++] = *pc;
}
}
/* copy last character if string len is odd */
if( iShift == 2 && sStrLen % 2 == 1 )
{
pcRet[sRetStrLen++] = pcString[sStrLen - 1];
}
hb_retclen( pcRet, sRetStrLen );
hb_xfree( pcRet );
}
else /* if (ISCHAR (1) && ISCHAR (2)) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode(), iError = 0;
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
switch ( iSwitch )
{
case DO_CHARONLY_CHARONLY:
iError = CT_ERROR_CHARONLY;
break;
case DO_CHARONLY_WORDONLY:
iError = CT_ERROR_WORDONLY;
break;
case DO_CHARONLY_CHARREM:
iError = CT_ERROR_CHARREM;
break;
case DO_CHARONLY_WORDREM:
iError = CT_ERROR_WORDREM;
break;
}
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG, iError,
NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| charonly.c | 69 |
HB_FUNC | CHARONLY(void)
HB_FUNC( CHARONLY )
{
do_charonly( DO_CHARONLY_CHARONLY );
}
| charonly.c | 218 |
HB_FUNC | WORDONLY(void)
HB_FUNC( WORDONLY )
{
do_charonly( DO_CHARONLY_WORDONLY );
}
| charonly.c | 263 |
HB_FUNC | CHARREM(void)
HB_FUNC( CHARREM )
{
do_charonly( DO_CHARONLY_CHARREM );
}
| charonly.c | 307 |
HB_FUNC | WORDREM(void)
HB_FUNC( WORDREM )
{
do_charonly( DO_CHARONLY_WORDREM );
}
| charonly.c | 352 |
charop.c |
Type | Function | Source | Line |
STATIC VOID | do_charop( int iSwitch )
static void do_charop( int iSwitch )
{
int iNoRet;
/* suppressing return value ? */
iNoRet = ct_getref() && ISBYREF( 1 );
if( ISCHAR( 1 ) )
{
size_t sStrLen = hb_parclen( 1 );
size_t sPos;
unsigned char *pucString = ( unsigned char * ) hb_parc( 1 );
unsigned char *pucResult;
if( sStrLen == 0 )
{
if( iNoRet )
{
hb_ret();
}
else
{
hb_retc( NULL );
}
return;
}
pucResult = ( unsigned char * ) hb_xgrab( sStrLen + 1 );
switch ( iSwitch )
{
/* NOT */
case DO_CHAROP_CHARNOT:
for( sPos = 0; sPos < sStrLen; sPos++ )
pucResult[sPos] = ~pucString[sPos];
break;
/* SHL */
case DO_CHAROP_CHARSHL:
{
int iSHL = ( hb_parni( 2 ) ) % 8; /* defaults to 0 */
if( iSHL == 0 )
hb_xmemcpy( pucResult, pucString, sStrLen );
else
for( sPos = 0; sPos < sStrLen; sPos++ )
pucResult[sPos] = pucString[sPos] << iSHL;
break;
}
/* SHR */
case DO_CHAROP_CHARSHR:
{
int iSHR = ( hb_parni( 2 ) ) % 8; /* defaults to 0 */
if( iSHR == 0 )
hb_xmemcpy( pucResult, pucString, sStrLen );
else
for( sPos = 0; sPos < sStrLen; sPos++ )
pucResult[sPos] = pucString[sPos] >> iSHR;
break;
}
/* RLL */
case DO_CHAROP_CHARRLL:
{
int iRLL = ( hb_parni( 2 ) ) % 8; /* defaults to 0 */
hb_xmemcpy( pucResult, pucString, sStrLen );
if( iRLL != 0 )
for( sPos = 0; sPos < sStrLen; sPos++ )
{
int iRLLCnt;
for( iRLLCnt = 0; iRLLCnt < iRLL; iRLLCnt++ )
if( pucResult[sPos] & 0x80 ) /* most left bit set -> roll over */
{
pucResult[sPos] <<= 1;
pucResult[sPos] |= 0x01;
}
else
{
pucResult[sPos] <<= 1;
}
}
break;
}
/* RLR */
case DO_CHAROP_CHARRLR:
{
int iRLR = ( hb_parni( 2 ) ) % 8; /* defaults to 0 */
hb_xmemcpy( pucResult, pucString, sStrLen );
if( iRLR != 0 )
for( sPos = 0; sPos < sStrLen; sPos++ )
{
int iRLRCnt;
for( iRLRCnt = 0; iRLRCnt < iRLR; iRLRCnt++ )
if( pucResult[sPos] & 0x01 ) /* most right bit set -> roll over */
{
pucResult[sPos] >>= 1;
pucResult[sPos] |= 0x80;
}
else
{
pucResult[sPos] >>= 1;
}
}
break;
}
/* ADD */
case DO_CHAROP_CHARADD:
{
if( ISCHAR( 2 ) )
{
char *pucString2 = hb_parc( 2 );
size_t sStrLen2 = hb_parclen( 2 );
for( sPos = 0; sPos < sStrLen; sPos++ )
pucResult[sPos] = ( char ) ( pucString[sPos] + pucString2[sPos % sStrLen2] );
}
else
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARADD,
NULL, "CHARADD", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_xmemcpy( pucResult, pucString, sStrLen );
}
break;
}
/* SUB */
case DO_CHAROP_CHARSUB:
{
if( ISCHAR( 2 ) )
{
char *pucString2 = hb_parc( 2 );
size_t sStrLen2 = hb_parclen( 2 );
for( sPos = 0; sPos < sStrLen; sPos++ )
pucResult[sPos] = ( char ) ( pucString[sPos] - pucString2[sPos % sStrLen2] );
}
else
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARSUB,
NULL, "CHARSUB", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_xmemcpy( pucResult, pucString, sStrLen );
}
break;
}
/* AND */
case DO_CHAROP_CHARAND:
{
if( ISCHAR( 2 ) )
{
char *pucString2 = hb_parc( 2 );
size_t sStrLen2 = hb_parclen( 2 );
for( sPos = 0; sPos < sStrLen; sPos++ )
pucResult[sPos] = ( char ) ( pucString[sPos] & pucString2[sPos % sStrLen2] );
}
else
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARAND, NULL, "CHARAND", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_xmemcpy( pucResult, pucString, sStrLen );
}
break;
}
/* OR */
case DO_CHAROP_CHAROR:
{
if( ISCHAR( 2 ) )
{
char *pucString2 = hb_parc( 2 );
size_t sStrLen2 = hb_parclen( 2 );
for( sPos = 0; sPos < sStrLen; sPos++ )
pucResult[sPos] = ( char ) ( pucString[sPos] | pucString2[sPos % sStrLen2] );
}
else
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHAROR, NULL, "CHAROR", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_xmemcpy( pucResult, pucString, sStrLen );
}
break;
}
/* XOR */
case DO_CHAROP_CHARXOR:
{
if( ISCHAR( 2 ) )
{
char *pucString2 = hb_parc( 2 );
size_t sStrLen2 = hb_parclen( 2 );
for( sPos = 0; sPos < sStrLen; sPos++ )
pucResult[sPos] = ( char ) ( pucString[sPos] ^ pucString2[sPos % sStrLen2] );
}
else
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARXOR, NULL, "CHARXOR", 0,
EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_xmemcpy( pucResult, pucString, sStrLen );
}
break;
}
} /* endswitch( iSwitch ) */
if( ISBYREF( 1 ) )
hb_storclen( ( char * ) pucResult, sStrLen, 1 );
if( iNoRet )
hb_xfree( pucResult );
else
hb_retclen_buffer( ( char * ) pucResult, sStrLen );
}
else /* if( ISCHAR( 1 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode(), iError = 0;
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
switch ( iSwitch )
{
case DO_CHAROP_CHARADD:
iError = CT_ERROR_CHARADD;
break;
case DO_CHAROP_CHARSUB:
iError = CT_ERROR_CHARSUB;
break;
case DO_CHAROP_CHARAND:
iError = CT_ERROR_CHARAND;
break;
case DO_CHAROP_CHARNOT:
iError = CT_ERROR_CHARNOT;
break;
case DO_CHAROP_CHAROR:
iError = CT_ERROR_CHAROR;
break;
case DO_CHAROP_CHARXOR:
iError = CT_ERROR_CHARXOR;
break;
case DO_CHAROP_CHARSHL:
iError = CT_ERROR_CHARSHL;
break;
case DO_CHAROP_CHARSHR:
iError = CT_ERROR_CHARSHR;
break;
case DO_CHAROP_CHARRLL:
iError = CT_ERROR_CHARRLL;
break;
case DO_CHAROP_CHARRLR:
iError = CT_ERROR_CHARRLR;
break;
}
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG, iError,
NULL, "CHARRLR", 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_ret();
}
}
| charop.c | 78 |
HB_FUNC | CHARADD(void)
HB_FUNC( CHARADD )
{
do_charop( DO_CHAROP_CHARADD );
}
| charop.c | 444 |
HB_FUNC | CHARSUB(void)
HB_FUNC( CHARSUB )
{
do_charop( DO_CHAROP_CHARSUB );
}
| charop.c | 500 |
HB_FUNC | CHARAND(void)
HB_FUNC( CHARAND )
{
do_charop( DO_CHAROP_CHARAND );
}
| charop.c | 555 |
HB_FUNC | CHARNOT(void)
HB_FUNC( CHARNOT )
{
do_charop( DO_CHAROP_CHARNOT );
}
| charop.c | 606 |
HB_FUNC | CHAROR(void)
HB_FUNC( CHAROR )
{
do_charop( DO_CHAROP_CHAROR );
}
| charop.c | 661 |
HB_FUNC | CHARXOR(void)
HB_FUNC( CHARXOR )
{
do_charop( DO_CHAROP_CHARXOR );
}
| charop.c | 714 |
HB_FUNC | CHARSHL(void)
HB_FUNC( CHARSHL )
{
do_charop( DO_CHAROP_CHARSHL );
}
| charop.c | 766 |
HB_FUNC | CHARSHR(void)
HB_FUNC( CHARSHR )
{
do_charop( DO_CHAROP_CHARSHR );
}
| charop.c | 818 |
HB_FUNC | CHARRLL(void)
HB_FUNC( CHARRLL )
{
do_charop( DO_CHAROP_CHARRLL );
}
| charop.c | 870 |
HB_FUNC | CHARRLR(void)
HB_FUNC( CHARRLR )
{
do_charop( DO_CHAROP_CHARRLR );
}
| charop.c | 922 |
charrepl.c |
Type | Function | Source | Line |
HB_FUNC | CHARREPL(void)
HB_FUNC( CHARREPL )
{
int iNoRet;
size_t sSearchLen, sReplaceLen;
/* suppressing return value ? */
iNoRet = ct_getref() && ISBYREF( 2 );
/* param check */
if( ( sSearchLen = ( size_t ) hb_parclen( 1 ) ) > 0 && ISCHAR( 2 ) &&
( sReplaceLen = ( size_t ) hb_parclen( 3 ) ) > 0 )
{
/* get parameters */
char *pcSearch = hb_parc( 1 );
char *pcString = hb_parc( 2 );
size_t sStrLen = ( size_t ) hb_parclen( 2 );
char *pcReplace = hb_parc( 3 );
int iMode;
char *pcRet;
size_t sIndex;
/* if sStrLen == 0, we can return immediately */
if( sStrLen == 0 )
{
if( iNoRet )
{
hb_retl( 0 );
}
else
{
hb_retc( NULL );
}
return;
}
if( ISLOG( 4 ) )
{
iMode = hb_parl( 4 );
}
else
{
iMode = 0;
}
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
hb_xmemcpy( pcRet, pcString, sStrLen );
for( sIndex = 0; sIndex < sSearchLen; sIndex++ )
{
size_t sMatchStrLen;
char *pc;
size_t sReplIndex = sIndex;
if( sReplIndex > sReplaceLen - 1 )
{
sReplIndex = sReplaceLen - 1;
}
if( iMode )
{
/* no multiple replacements: searching in pcString,
replacing in pcRet */
pc = pcString;
while( ( pc = ct_at_exact_forward( pc, sStrLen - ( pc - pcString ),
pcSearch + sIndex, 1,
&sMatchStrLen ) ) != NULL )
{
*( pcRet + ( pc - pcString ) ) = *( pcReplace + sReplIndex );
pc++;
}
}
else
{
/* multiple replacements: searching & replacing in pcRet */
pc = pcRet;
while( ( pc = ct_at_exact_forward( pc, sStrLen - ( pc - pcRet ),
pcSearch + sIndex, 1,
&sMatchStrLen ) ) != NULL )
{
*pc++ = *( pcReplace + sReplIndex );
}
}
}
/* return string */
if( ISBYREF( 2 ) )
{
hb_storclen( pcRet, sStrLen, 2 );
}
if( iNoRet )
{
hb_retl( 0 );
hb_xfree( pcRet );
}
else
{
hb_retclen_buffer( pcRet, sStrLen );
}
}
else /* ( ( sSearchLen = ( size_t ) hb_parclen( 1 ) ) > 0 && ISCHAR( 2 ) &&
( sReplaceLen = ( size_t ) hb_parclen( 3 ) ) > 0 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CHARREPL, NULL, "CHARREPL", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_retl( 0 );
else if( ISCHAR( 2 ) )
hb_retclen( hb_parc( 2 ), hb_parclen( 2 ) );
else
hb_retc( NULL );
}
}
| charrepl.c | 123 |
charsort.c |
Type | Function | Source | Line |
_HB_DO_SORTASCEND( | const void *p1, const void *p2 )
_hb_do_sortascend( const void *p1, const void *p2 )
{
char *pc1 = ( char * ) p1;
char *pc2 = ( char * ) p2;
pc1 += ssElementPos;
pc2 += ssElementPos;
return strncmp( pc1, pc2, ssCompareLen );
}
#ifdef __IBMCPP__
int extern _LNK_CONV
#else
static int
| charsort.c | 67 |
_HB_DO_SORTDESCEND( | const void *p1, const void *p2 )
_hb_do_sortdescend( const void *p1, const void *p2 )
{
char *pc1 = ( char * ) p1;
char *pc2 = ( char * ) p2;
pc1 += ssElementPos;
pc2 += ssElementPos;
return -strncmp( pc1, pc2, ssCompareLen );
}
| charsort.c | 83 |
HB_FUNC | CHARSORT(void)
HB_FUNC( CHARSORT )
{
int iNoRet;
/* suppressing return value ? */
iNoRet = ct_getref() && ISBYREF( 1 );
/* param check I */
if( ISCHAR( 1 ) )
{
/* get parameters */
char *pcString = hb_parc( 1 );
char *pcRet;
size_t sStrLen = ( size_t ) hb_parclen( 1 );
size_t sElementLen, sIgnore, sSortLen;
int iDescend;
if( ISNUM( 2 ) )
sElementLen = hb_parnl( 2 );
else
sElementLen = 1;
if( ISNUM( 3 ) )
ssCompareLen = hb_parnl( 3 );
else
ssCompareLen = sElementLen;
if( ISNUM( 4 ) )
sIgnore = hb_parnl( 4 );
else
sIgnore = 0;
if( ISNUM( 5 ) )
ssElementPos = hb_parnl( 5 );
else
ssElementPos = 0;
if( ISNUM( 6 ) )
sSortLen = hb_parnl( 6 );
else
sSortLen = sStrLen - sIgnore;
if( ISLOG( 7 ) )
iDescend = hb_parl( 7 );
else
iDescend = 0;
/* param check II */
if( sElementLen == 0 || ssCompareLen > sElementLen ||
sIgnore + sElementLen > sStrLen ||
ssElementPos + ssCompareLen > sElementLen ||
sSortLen + sIgnore > sStrLen )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CHARSORT,
NULL, "CHARSORT", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
if( iNoRet )
hb_retl( 0 );
else
hb_retc( NULL );
return;
}
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
hb_xmemcpy( pcRet, pcString, sStrLen );
if( iDescend )
qsort( pcRet + sIgnore, ( sSortLen / sElementLen ), sElementLen, _hb_do_sortdescend );
else
qsort( pcRet + sIgnore, ( sSortLen / sElementLen ), sElementLen, _hb_do_sortascend );
/* return string */
if( ISBYREF( 1 ) )
hb_storclen( pcRet, sStrLen, 1 );
if( iNoRet )
{
hb_retl( 0 );
hb_xfree( pcRet );
}
else
hb_retclen_buffer( pcRet, sStrLen );
}
else /* if( ISCHAR( 1 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CHARSORT, NULL, "CHARSORT", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_retl( 0 );
else
hb_retc( NULL );
}
}
| charsort.c | 176 |
charsprd.c |
Type | Function | Source | Line |
HB_FUNC | CHARSPREAD(void)
HB_FUNC( CHARSPREAD )
{
ULONG ulLen = hb_parclen( 1 );
if( ulLen == 0 )
hb_retc( NULL );
else
{
long lSize = hb_parnl( 2 );
if( lSize < 0 || ( ULONG ) lSize <= ulLen )
hb_itemReturn( hb_param( 1, HB_IT_ANY ) );
else
{
char * szText = hb_parc( 1 ), * szDest, cDelim = ' ';
int iTokens = 0, iRepl, iRest, iFirst, i;
ULONG ul, ulDst, ulRest;
if( ISCHAR( 3 ) )
cDelim = hb_parc( 3 )[0];
else if( ISNUM( 3 ) )
cDelim = ( char ) hb_parni( 3 );
for( ul = 0; ul < ulLen; ++ul )
{
if( szText[ul] == cDelim )
{
iTokens++;
while( ul + 1 < ulLen && szText[ul + 1] == cDelim )
++ul;
}
}
if( iTokens == 0 )
{
hb_itemReturn( hb_param( 1, HB_IT_ANY ) );
}
else
{
ulRest = ( ULONG ) lSize - ulLen;
iRepl = ulRest / iTokens;
iRest = ulRest % iTokens;
iFirst = ( iRest + 1 ) >> 1;
iRest >>= 1;
szDest = ( char * ) hb_xgrab( lSize + 1 );
for( ulDst = ul = 0; ul < ulLen; ++ul )
{
szDest[ulDst++] = szText[ul];
if( szText[ul] == cDelim )
{
while( ul + 1 < ulLen && szText[ul + 1] == cDelim )
szDest[ulDst++] = szText[++ul];
i = iRepl;
if( iFirst )
{
--iFirst;
++i;
}
else if( iTokens <= iRest )
++i;
while( --i >= 0 )
szDest[ulDst++] = cDelim;
iTokens--;
}
}
hb_retclen_buffer( szDest, lSize );
}
}
}
}
| charsprd.c | 57 |
charswap.c |
Type | Function | Source | Line |
STATIC VOID | do_charswap( int iSwitch )
static void do_charswap( int iSwitch )
{
int iNoRet;
/* suppress return value ? */
iNoRet = ct_getref() && ISBYREF( 1 );
/* param check */
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcRet;
size_t sRetIndex = 0;
int iShift, iMod;
char *pcSub;
if( sStrLen == 0 )
{
if( iNoRet )
hb_ret();
else
hb_retc( NULL );
return;
}
if( iSwitch == DO_CHARSWAP_WORDSWAP )
{
iShift = 4;
if( ISLOG( 2 ) && hb_parl( 2 ) )
{
iSwitch = DO_CHARSWAP_WORDSWAP_CHARSWAP;
}
}
else
{
iShift = 2;
}
pcRet = ( char * ) hb_xgrab( sStrLen );
for( pcSub = pcString; pcSub < pcString + sStrLen + 1 - iShift; pcSub += iShift )
{
switch ( iSwitch )
{
case DO_CHARSWAP_WORDSWAP:
pcRet[sRetIndex++] = pcSub[2];
pcRet[sRetIndex++] = pcSub[3];
pcRet[sRetIndex++] = pcSub[0];
pcRet[sRetIndex++] = pcSub[1];
break;
case DO_CHARSWAP_WORDSWAP_CHARSWAP:
pcRet[sRetIndex++] = pcSub[3];
pcRet[sRetIndex++] = pcSub[2];
/* no 'break' here !! */
case DO_CHARSWAP_CHARSWAP:
pcRet[sRetIndex++] = pcSub[1];
pcRet[sRetIndex++] = pcSub[0];
}
}
/* copy rest of string */
if( ( iSwitch == DO_CHARSWAP_WORDSWAP ) || ( iSwitch == DO_CHARSWAP_WORDSWAP_CHARSWAP ) )
{
iMod = sStrLen % 4;
}
else
{
iMod = sStrLen % 2;
}
for( pcSub = pcString + sStrLen - iMod; pcSub < pcString + sStrLen; pcSub++ )
{
pcRet[sRetIndex++] = *pcSub;
}
/* return string */
if( ISBYREF( 1 ) )
{
hb_storclen( pcRet, sRetIndex, 1 );
}
if( iNoRet )
hb_retl( 0 );
else
hb_retclen( pcRet, sRetIndex );
hb_xfree( pcRet );
}
else /* if (ISCHAR (1)) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
if( iSwitch == DO_CHARSWAP_CHARSWAP )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CHARSWAP,
NULL, "CHARSWAP", 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
else
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_WORDSWAP,
NULL, "WORDSWAP", 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_retl( 0 );
else
hb_retc( NULL );
}
}
| charswap.c | 66 |
HB_FUNC | CHARSWAP(void)
HB_FUNC( CHARSWAP )
{
do_charswap( DO_CHARSWAP_CHARSWAP );
}
| charswap.c | 227 |
HB_FUNC | WORDSWAP(void)
HB_FUNC( WORDSWAP )
{
do_charswap( DO_CHARSWAP_WORDSWAP );
}
| charswap.c | 277 |
color.c |
Type | Function | Source | Line |
HB_FUNC | INVERTATTR(void)
HB_FUNC( INVERTATTR )
{
int iAttr;
if( ISCHAR( 1 ) )
{
iAttr = hb_gtColorToN( hb_parc( 1 ) );
if( iAttr == -1 )
iAttr = 0;
}
else
iAttr = hb_parni( 1 );
hb_retni( ( iAttr & 0x88 ) |
( ( iAttr & 0x07 ) << 4 ) |
( ( iAttr >> 4 ) & 0x07 ) );
}
| color.c | 85 |
HB_FUNC | COLORTON(void)
HB_FUNC( COLORTON )
{
if( ISCHAR( 1 ) )
{
int iColor = hb_gtColorToN( hb_parc( 1 ) );
hb_retni( iColor == -1 ? 0 : iColor );
}
else
hb_retni( hb_parni( 1 ) );
}
| color.c | 142 |
HB_FUNC | NTOCOLOR(void)
HB_FUNC( NTOCOLOR )
{
char szColorString[ 10 ];
int iColor;
iColor = ISNUM( 1 ) ? hb_parni( 1 ) : -1;
if( iColor >= 0x00 && iColor <= 0xff )
{
if( ISLOG( 2 ) && hb_parl( 2 ) )
hb_gtColorsToString( &iColor, 1, szColorString, 10 );
else
snprintf( szColorString, 10, "%02d/%02d", iColor & 0x0f, iColor >> 4 );
hb_retc( szColorString );
}
else
hb_retc( NULL );
}
| color.c | 194 |
HB_FUNC | ENHANCED(void)
HB_FUNC( ENHANCED )
{
hb_gtColorSelect( HB_CLR_ENHANCED );
hb_retc( NULL );
}
| color.c | 242 |
HB_FUNC | STANDARD(void)
HB_FUNC( STANDARD )
{
hb_gtColorSelect( HB_CLR_STANDARD );
hb_retc( NULL );
}
| color.c | 277 |
HB_FUNC | UNSELECTED(void)
HB_FUNC( UNSELECTED )
{
hb_gtColorSelect( HB_CLR_UNSELECTED );
hb_retc( NULL );
}
| color.c | 312 |
count.c |
Type | Function | Source | Line |
STATIC VOID | do_count( int iSwitch )
static void do_count( int iSwitch )
{
/* param check */
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
size_t sRetVal;
char *pc;
char cSearch;
if( hb_parclen( 2 ) > 0 )
cSearch = *( hb_parc( 2 ) );
else if( ISNUM( 2 ) )
cSearch = ( char ) ( hb_parnl( 2 ) % 256 );
else
cSearch = 0x20;
sRetVal = 0;
switch ( iSwitch )
{
case DO_COUNT_COUNTLEFT:
pc = pcString;
while( ( *pc == cSearch ) && ( pc < pcString + sStrLen ) )
{
sRetVal++;
pc++;
}
break;
case DO_COUNT_COUNTRIGHT:
pc = pcString + sStrLen - 1;
while( ( *pc == cSearch ) && ( pc >= pcString ) )
{
sRetVal++;
pc--;
}
break;
}
hb_retnl( sRetVal );
}
else /* if( ISCHAR( 1 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_COUNT_COUNTLEFT ?
CT_ERROR_COUNTLEFT : CT_ERROR_COUNTRIGHT,
NULL, HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| count.c | 61 |
HB_FUNC | COUNTLEFT(void)
HB_FUNC( COUNTLEFT )
{
do_count( DO_COUNT_COUNTLEFT );
}
| count.c | 155 |
HB_FUNC | COUNTRIGHT(void)
HB_FUNC( COUNTRIGHT )
{
do_count( DO_COUNT_COUNTRIGHT );
}
| count.c | 189 |
ctc.c |
Type | Function | Source | Line |
USHORT | ct_error( USHORT uiSeverity, ULONG ulGenCode, ULONG ulSubCode, const char *szDescription, const char *szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... )
USHORT ct_error( USHORT uiSeverity, ULONG ulGenCode, ULONG ulSubCode,
const char *szDescription, const char *szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... )
{
USHORT uiAction;
PHB_ITEM pError;
PHB_ITEM pArray;
va_list va;
ULONG ulArgPos;
HB_TRACE( HB_TR_DEBUG, ( "ct_error(%hu, %lu, %lu, %s, %s, %hu, %hu, %lu)",
uiSeverity, ulGenCode, ulSubCode, szDescription, szOperation, uiOsCode, uiFlags, ulArgCount ) );
pError = hb_errRT_New( uiSeverity, CT_SUBSYSTEM, ulGenCode, ulSubCode, szDescription, szOperation, uiOsCode, uiFlags );
/* Build the array from the passed arguments. */
if( ulArgCount == 0 )
{
pArray = NULL;
}
else if( ulArgCount == HB_ERR_ARGS_BASEPARAMS )
{
if( hb_pcount() == 0 )
pArray = NULL;
else
pArray = hb_arrayBaseParams();
}
else if( ulArgCount == HB_ERR_ARGS_SELFPARAMS )
{
pArray = hb_arraySelfParams();
}
else
{
pArray = hb_itemArrayNew( ulArgCount );
va_start( va, ulArgCount );
for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ )
{
hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) );
}
va_end( va );
}
if( pArray )
{
/* Assign the new array to the object data item. */
hb_vmPushSymbol( hb_dynsymGetSymbol( "_ARGS" ) );
hb_vmPush( pError );
hb_vmPush( pArray );
hb_vmSend( 1 );
/* Release the Array. */
hb_itemRelease( pArray );
}
/* launch error codeblock */
uiAction = hb_errLaunch( pError );
/* release error codeblock */
hb_errRelease( pError );
return uiAction;
}
| ctc.c | 60 |
PHB_ITEM | ct_error_subst( USHORT uiSeverity, ULONG ulGenCode, ULONG ulSubCode, const char *szDescription, const char *szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... )
PHB_ITEM ct_error_subst( USHORT uiSeverity, ULONG ulGenCode, ULONG ulSubCode,
const char *szDescription, const char *szOperation, USHORT uiOsCode, USHORT uiFlags, ULONG ulArgCount, ... )
{
PHB_ITEM pRetVal;
PHB_ITEM pError;
PHB_ITEM pArray;
va_list va;
ULONG ulArgPos;
HB_TRACE( HB_TR_DEBUG, ( "ct_error_subst(%hu, %lu, %lu, %s, %s, %hu, %hu, %lu)",
uiSeverity, ulGenCode, ulSubCode, szDescription, szOperation, uiOsCode, uiFlags, ulArgCount ) );
pError = hb_errRT_New_Subst( uiSeverity, CT_SUBSYSTEM, ulGenCode, ulSubCode, szDescription, szOperation, uiOsCode, uiFlags );
/* Build the array from the passed arguments. */
if( ulArgCount == 0 )
{
pArray = NULL;
}
else if( ulArgCount == HB_ERR_ARGS_BASEPARAMS )
{
if( hb_pcount() == 0 )
pArray = NULL;
else
pArray = hb_arrayBaseParams();
}
else if( ulArgCount == HB_ERR_ARGS_SELFPARAMS )
{
pArray = hb_arraySelfParams();
}
else
{
pArray = hb_itemArrayNew( ulArgCount );
va_start( va, ulArgCount );
for( ulArgPos = 1; ulArgPos <= ulArgCount; ulArgPos++ )
{
hb_itemArrayPut( pArray, ulArgPos, va_arg( va, PHB_ITEM ) );
}
va_end( va );
}
if( pArray )
{
/* Assign the new array to the object data item. */
hb_vmPushSymbol( hb_dynsymGetSymbol( "_ARGS" ) );
hb_vmPush( pError );
hb_vmPush( pArray );
hb_vmSend( 1 );
/* Release the Array. */
hb_itemRelease( pArray );
}
/* launch error codeblock */
pRetVal = hb_errLaunchSubst( pError );
hb_errRelease( pError );
return pRetVal;
}
/* argument error behaviour */
static int s_iArgErrMode = CT_ARGERR_IGNORE;
| ctc.c | 127 |
VOID | ct_setargerrormode( int iMode )
void ct_setargerrormode( int iMode )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_setargerrormode(%i)", iMode ) );
s_iArgErrMode = iMode;
}
| ctc.c | 195 |
INT | ct_getargerrormode( void )
int ct_getargerrormode( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_getargerrormode()" ) );
return s_iArgErrMode;
}
| ctc.c | 201 |
HB_FUNC | CSETARGERR(void)
HB_FUNC( CSETARGERR )
{
hb_retni( ct_getargerrormode() );
if( ISNUM( 1 ) )
{
int iNewMode = hb_parni( 1 );
if( iNewMode == CT_ARGERR_WHOCARES ||
iNewMode == CT_ARGERR_WARNING ||
iNewMode == CT_ARGERR_ERROR ||
iNewMode == CT_ARGERR_CATASTROPHIC ||
iNewMode == CT_ARGERR_IGNORE )
{
ct_setargerrormode( hb_parni( 1 ) );
}
else
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CSETARGERR,
NULL, "CSETARGERR", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
}
}
else if( hb_pcount() > 0 ) /* more than one param but not integer */
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CSETARGERR, NULL,
"CSETARGERR", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
}
}
/* initialization */
static int s_initialized = 0; /* TODO: make this thread safe */
| ctc.c | 247 |
HB_FUNC | CTCINIT(void)
HB_FUNC( CTCINIT )
{
if( s_initialized == 0 )
{
int iSuccess;
iSuccess = ct_str_init();
iSuccess |= ct_math_init();
s_initialized = iSuccess;
}
hb_retl( s_initialized );
}
| ctc.c | 321 |
HB_FUNC | CTCEXIT(void)
HB_FUNC( CTCEXIT )
{
ct_str_exit();
ct_math_exit();
s_initialized = 0;
hb_ret();
}
| ctc.c | 366 |
ctchksum.c |
Type | Function | Source | Line |
HB_FUNC | CHECKSUM(void)
HB_FUNC( CHECKSUM )
{
UCHAR *pbyString = ( UCHAR * ) hb_parc( 1 );
ULONG ulLen = hb_parclen( 1 );
ULONG ulPos;
ULONG ulResult = 0;
for( ulPos = 0; ulPos < ulLen; ulPos++ )
ulResult += pbyString[ulPos] | ( pbyString[ulPos + 1] << 8 );
hb_retnint( ( ULONG ) ( ( ulResult & 0x00FFFFFF ) | ( ( ulLen & 0xFF ) << 24 ) ) );
}
| ctchksum.c | 55 |
ctcrypt.c |
Type | Function | Source | Line |
HB_FUNC | CRYPT(void)
HB_FUNC( CRYPT )
{
ULONG ulCryptLen = hb_parclen( 2 );
if( ulCryptLen >= 2 )
{
BYTE *pbyCrypt = ( BYTE * ) hb_parc( 2 );
ULONG ulCryptPos = 0;
BYTE *pbyString = ( BYTE * ) hb_parc( 1 );
ULONG ulStringLen = hb_parclen( 1 );
ULONG ulStringPos;
BYTE *pbyResult = ( BYTE * ) hb_xgrab( ulStringLen + 1 );
USHORT uiCount2 =
( ( ( USHORT ) ( pbyCrypt[ulCryptPos] + ( USHORT ) ( pbyCrypt[ulCryptPos + 1] * 256 ) ) ) &
0xFFFF ) ^ ( ( USHORT ) ulCryptLen & 0xFFFF );
USHORT uiCount1 = 0xAAAA;
for( ulStringPos = 0; ulStringPos < ulStringLen; )
{
USHORT uiTmpCount1 = uiCount1;
USHORT uiTmpCount2 = uiCount2;
BYTE byte = pbyString[ulStringPos] ^ pbyCrypt[ulCryptPos++];
USHORT tmp;
uiTmpCount2 =
HB_MKUSHORT( ( HB_LOBYTE( uiTmpCount2 ) ^ HB_HIBYTE( uiTmpCount2 ) ),
HB_HIBYTE( uiTmpCount2 ) );
for( tmp = HB_LOBYTE( uiTmpCount2 ); tmp; tmp-- )
uiTmpCount2 = ( uiTmpCount2 >> 1 ) | ( ( uiTmpCount2 & 1 ) << 15 );
uiTmpCount2 ^= uiTmpCount1;
uiTmpCount2 += 16;
uiCount2 = uiTmpCount2;
uiTmpCount2 &= 0x1E;
uiTmpCount2 += 2;
do
{
BYTE byTmp;
uiTmpCount2--;
for( tmp = HB_LOBYTE( uiTmpCount2 ); tmp; tmp-- )
uiTmpCount1 = ( uiTmpCount1 >> 1 ) | ( ( uiTmpCount1 & 1 ) << 15 );
uiTmpCount1 = HB_MKUSHORT( HB_HIBYTE( uiTmpCount1 ), HB_LOBYTE( uiTmpCount1 ) );
uiTmpCount1 =
HB_MKUSHORT( ( HB_LOBYTE( uiTmpCount1 ) ^ 0xFF ), HB_HIBYTE( uiTmpCount1 ) );
uiTmpCount1 = ( uiTmpCount1 << 1 ) | ( ( uiTmpCount1 & 0x8000 ) >> 15 );
uiTmpCount1 ^= 0xAAAA;
byTmp = HB_LOBYTE( uiTmpCount1 );
byTmp = ( byTmp << 1 ) | ( ( byTmp & 0x80 ) >> 7 );
uiTmpCount1 = HB_MKUSHORT( byTmp, HB_HIBYTE( uiTmpCount1 ) );
}
while( --uiTmpCount2 );
uiCount1 = uiTmpCount1;
pbyResult[ulStringPos++] = byte ^ HB_LOBYTE( uiTmpCount1 );
if( ulCryptPos == ulCryptLen )
ulCryptPos = 0;
}
hb_retclen_buffer( ( char * ) pbyResult, ulStringLen );
}
else
hb_retc( NULL );
}
| ctcrypt.c | 55 |
ctmath.c |
Type | Function | Source | Line |
INT | ct_math_init( void )
/* initialization */
/* ---------------- */
int ct_math_init( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_math_init()" ) );
return 1;
}
| ctmath.c | 57 |
INT | ct_math_exit( void )
int ct_math_exit( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_math_exit()" ) );
return 1;
}
/* ---------------- */
/* math precision */
static int s_ct_precision = 16; /* TODO: make this thread safe */
| ctmath.c | 66 |
VOID | ct_setprecision( int iPrecision )
void ct_setprecision( int iPrecision )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_setprecision (%i)", iPrecision ) );
s_ct_precision = iPrecision;
}
| ctmath.c | 77 |
INT | ct_getprecision( void )
int ct_getprecision( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_getprecision()" ) );
return s_ct_precision;
}
| ctmath.c | 83 |
HB_FUNC | SETPREC(void)
HB_FUNC( SETPREC )
{
int iPrec = hb_parni( 1 );
if( iPrec >= 1 && iPrec <= 16 )
ct_setprecision( iPrec );
else
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_SETPREC, NULL,
"SETPREC", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
}
| ctmath.c | 120 |
HB_FUNC | GETPREC(void)
HB_FUNC( GETPREC )
{
hb_retni( ct_getprecision() );
if( hb_pcount() > 0 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_GETPREC, NULL,
"GETPREC", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
}
| ctmath.c | 167 |
ctmath2.c |
Type | Function | Source | Line |
HB_FUNC | FLOOR(void)
HB_FUNC( FLOOR )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = floor( dArg );
if( hb_mathGetError( &hb_exc, "FLOOR", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
hb_retnlen( 0, 0, 0 );
}
else
hb_retnlen( dResult, 0, 0 );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst =
ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_FLOOR, NULL, "FLOOR", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| ctmath2.c | 104 |
HB_FUNC | CEILING(void)
HB_FUNC( CEILING )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = ceil( dArg );
if( hb_mathGetError( &hb_exc, "CEIL", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
hb_retnlen( 0, 0, 0 );
}
else
hb_retnlen( dResult, 0, 0 );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CEILING, NULL, "CEILING", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| ctmath2.c | 177 |
HB_FUNC | SIGN(void)
HB_FUNC( SIGN )
{
if( ISNUM( 1 ) )
{
double dInput = hb_parnd( 1 );
int iResult;
if( dInput == 0.00 )
iResult = 0;
else
{
if( dInput > 0.00 )
iResult = 1;
else
iResult = -1;
}
hb_retni( iResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_SIGN, NULL, "SIGN", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| ctmath2.c | 253 |
HB_FUNC | LOG10(void)
HB_FUNC( LOG10 )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = log10( dArg );
if( hb_mathGetError( &hb_exc, "LOG10", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
{
/* math exception is up to the Harbour function, so do this as Clipper compatible as possible */
switch( hb_exc.type )
{
case HB_MATH_ERR_SING: /* argument to log was 0.0 */
case HB_MATH_ERR_DOMAIN: /* argument to log was < 0.0 */
hb_retndlen( -HUGE_VAL, -1, -1 ); /* return -infinity */
break;
default:
hb_retnd( 0.0 );
break;
}
}
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_LOG10, NULL, "LOG10", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| ctmath2.c | 324 |
HB_FUNC | FACT(void)
HB_FUNC( FACT )
{
if( ISNUM( 1 ) )
{
int iInput = hb_parni( 1 );
int i;
double dResult = 1.0;
if( ( iInput >= 0 ) && ( iInput < 22 ) )
{
for( i = 1; i <= iInput; i++ )
dResult *= ( double ) i;
hb_retnd( dResult );
}
else
hb_retnd( -1.0 );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_FACT, NULL, "FACT", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| ctmath2.c | 413 |
ctnet.c |
Type | Function | Source | Line |
BOOL WINAPI | WNetErrorHandler( DWORD dwErrorCode, LPSTR lpszFunction )
BOOL WINAPI WNetErrorHandler( DWORD dwErrorCode, LPSTR lpszFunction )
{
HB_ITEM_PTR pError;
if( dwErrorCode != ERROR_EXTENDED_ERROR )
{
pError = hb_errRT_New( ES_ERROR,
"CT",
9001,
0,
"Windows Network operation failed",
lpszFunction, ( USHORT ) dwErrorCode, EF_NONE );
hb_errLaunch( pError );
hb_itemRelease( pError );
}
else
{
DWORD dwLastError, dwWNetResult;
TCHAR lpDescription[256], lpProvider[256];
char * szDescription, * szProvider;
dwWNetResult = WNetGetLastError( &dwLastError, lpDescription, 256,
lpProvider, 256 );
if( dwWNetResult != NO_ERROR )
{
pError = hb_errRT_New( ES_ERROR, "CT", 9002, 0,
"WNetGetLastError failed", "see OS error",
( USHORT ) dwWNetResult, EF_NONE );
hb_errLaunch( pError );
hb_itemRelease( pError );
return FALSE;
}
szDescription = HB_TCHAR_CONVFROM( lpDescription );
szProvider = HB_TCHAR_CONVFROM( lpProvider );
pError = hb_errRT_New( ES_ERROR, "CT", 9003, 0,
szDescription, szProvider,
( USHORT ) dwLastError, EF_NONE );
HB_TCHAR_FREE( szDescription );
HB_TCHAR_FREE( szProvider );
hb_errLaunch( pError );
hb_itemRelease( pError );
}
return TRUE;
}
| ctnet.c | 98 |
STATIC BOOL | hb_IsNetShared( LPSTR szLocalDevice )
static BOOL hb_IsNetShared( LPSTR szLocalDevice )
{
TCHAR lpRemoteDevice[80];
LPTSTR lpLocalDevice;
DWORD cchBuff = sizeof( lpRemoteDevice ) / sizeof( TCHAR );
DWORD dwResult;
lpLocalDevice = HB_TCHAR_CONVTO( szLocalDevice );
dwResult = WNetGetConnection( ( LPTSTR ) lpLocalDevice,
( LPTSTR ) lpRemoteDevice, &cchBuff );
HB_TCHAR_FREE( lpLocalDevice );
return dwResult == NO_ERROR;
}
| ctnet.c | 147 |
HB_FUNC | NETCANCEL(void)
HB_FUNC( NETCANCEL )
{
DWORD dwResult;
LPTSTR lpDevice = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
dwResult = WNetCancelConnection( lpDevice, TRUE ); /* FALSE = fail if exist open files or print jobs. */
HB_TCHAR_FREE( lpDevice );
/* TRUE = force cancel connection even if exist
* open files or print jobs.
*/
hb_retl( dwResult == NO_ERROR );
}
| ctnet.c | 162 |
HB_FUNC | NETPRINTER(void)
HB_FUNC( NETPRINTER )
{
char * cPrn = hb_setGetCPtr( HB_SET_PRINTFILE ); /* query default local printer port. */
if( !cPrn || !*cPrn || hb_stricmp( cPrn, "PRN" ) == 0 )
cPrn = "LPT1";
hb_retl( hb_IsNetShared( cPrn ) );
}
| ctnet.c | 177 |
HB_FUNC | NETDISK(void)
HB_FUNC( NETDISK )
{
char cDrive[3];
cDrive[0] = hb_parcx( 1 )[0];
cDrive[1] = ':';
cDrive[2] = '\0';
hb_retl( hb_IsNetShared( cDrive ) );
}
| ctnet.c | 187 |
HB_FUNC | NETREDIR(void)
HB_FUNC( NETREDIR )
{
DWORD dwResult;
LPTSTR lpLocalDev = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
LPTSTR lpSharedRes = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
LPTSTR lpPassword = HB_TCHAR_CONVTO( hb_parcx( 3 ) );
BOOL bShowError = ( ISLOG( 4 ) ? hb_parl( 4 ) : FALSE );
if( hb_pcount() >= 3 && ISCHAR( 3 ) )
dwResult = WNetAddConnection( lpSharedRes, lpPassword, lpLocalDev );
else
dwResult = WNetAddConnection( lpSharedRes, NULL, lpLocalDev );
if( dwResult == NO_ERROR )
hb_retl( TRUE );
else
{
if( bShowError )
{
char szCommand[80];
snprintf( szCommand, 80, "NETREDIR( \"%s\", \"%s\", \"%s\" )",
hb_parcx( 1 ), hb_parcx( 2 ), hb_parcx( 3 ) );
WNetErrorHandler( dwResult, szCommand );
}
hb_retl( FALSE );
}
}
| ctnet.c | 199 |
HB_FUNC | NETRMTNAME(void)
HB_FUNC( NETRMTNAME )
{
TCHAR lpRemoteDevice[80];
LPTSTR lpLocalDevice;
DWORD cchBuff = sizeof( lpRemoteDevice ) / sizeof( TCHAR );
DWORD dwResult;
char *szRemoteDevice;
lpLocalDevice = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
dwResult = WNetGetConnection( ( LPTSTR ) lpLocalDevice,
( LPTSTR ) lpRemoteDevice, &cchBuff );
HB_TCHAR_FREE( lpLocalDevice );
szRemoteDevice = HB_TCHAR_CONVFROM( lpRemoteDevice );
hb_retc( dwResult == NO_ERROR ? szRemoteDevice : NULL );
HB_TCHAR_FREE( szRemoteDevice );
}
| ctnet.c | 227 |
HB_FUNC | NETWORK(void)
HB_FUNC( NETWORK )
{
DWORD dwResult;
TCHAR lpProviderName[80];
DWORD cchBuff = sizeof( lpProviderName ) / sizeof( TCHAR );
dwResult = WNetGetProviderName( WNNC_NET_MSNET, lpProviderName, &cchBuff );
if( dwResult != NO_ERROR )
{
dwResult = WNetGetProviderName( WNNC_NET_LANMAN, lpProviderName, &cchBuff );
if( dwResult != NO_ERROR )
dwResult = WNetGetProviderName( WNNC_NET_NETWARE, lpProviderName, &cchBuff );
}
hb_retl( dwResult == NO_ERROR );
}
| ctnet.c | 245 |
HB_FUNC | NNETWORK(void)
HB_FUNC( NNETWORK )
{
DWORD dwResult;
TCHAR lpProviderName[80];
DWORD cchBuff = sizeof( lpProviderName ) / sizeof( TCHAR );
dwResult = WNetGetProviderName( WNNC_NET_NETWARE, lpProviderName, &cchBuff );
hb_retl( dwResult == NO_ERROR );
}
| ctnet.c | 265 |
ctpad.c |
Type | Function | Source | Line |
STATIC VOID | do_pad( int iSwitch )
static void do_pad( int iSwitch )
{
if( ISCHAR( 1 ) && ISNUM( 2 ) )
{
char *pcString = ( char * ) hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcRet, *pc;
LONG lRetLen;
size_t sRetLen;
char cFill;
lRetLen = hb_parnl( 2 );
if( lRetLen <= 0 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_PAD_PADLEFT ?
CT_ERROR_PADLEFT : CT_ERROR_PADRIGHT, NULL,
HB_ERR_FUNCNAME, 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
return;
}
sRetLen = ( size_t ) lRetLen;
if( hb_parclen( 3 ) > 0 )
cFill = *( hb_parc( 3 ) );
else if( ISNUM( 3 ) )
cFill = ( char ) ( hb_parnl( 3 ) % 256 );
else
cFill = 0x20;
pcRet = ( char * ) hb_xgrab( sRetLen + 1 );
if( iSwitch == DO_PAD_PADLEFT )
{
if( sRetLen > sStrLen )
{
/* fill with cFill */
for( pc = pcRet; pc < pcRet + ( sRetLen - sStrLen ); pc++ )
*pc = cFill;
hb_xmemcpy( pcRet + ( sRetLen - sStrLen ), pcString, sStrLen );
}
else
{
hb_xmemcpy( pcRet, pcString + ( sStrLen - sRetLen ), sRetLen );
}
}
else
{
hb_xmemcpy( pcRet, pcString, ( sRetLen < sStrLen ? sRetLen : sStrLen ) );
if( sRetLen > sStrLen )
{
/* fill with cFill */
for( pc = pcRet + sStrLen; pc < pcRet + sRetLen; pc++ )
*pc = cFill;
}
}
hb_retclen_buffer( pcRet, sRetLen );
}
else /* ISCHAR( 1 ) && ISNUM( 2 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_PAD_PADLEFT ?
CT_ERROR_PADLEFT : CT_ERROR_PADRIGHT, NULL,
HB_ERR_FUNCNAME, 0, EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| ctpad.c | 61 |
HB_FUNC | PADLEFT(void)
HB_FUNC( PADLEFT )
{
do_pad( DO_PAD_PADLEFT );
}
| ctpad.c | 176 |
HB_FUNC | PADRIGHT(void)
HB_FUNC( PADRIGHT )
{
do_pad( DO_PAD_PADRIGHT );
}
| ctpad.c | 210 |
ctstr.c |
Type | Function | Source | Line |
INT | ct_str_init( void )
/* initialization */
/* -------------- */
int ct_str_init( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ctstr_init()" ) );
return 1;
}
| ctstr.c | 59 |
INT | ct_str_exit( void )
int ct_str_exit( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ctstr_exit()" ) );
return 1;
}
| ctstr.c | 68 |
CHAR | ct_at_exact_forward( char *pcString, size_t sStrLen, char *pcMatch, size_t sMatchLen, size_t * psMatchStrLen )
/* search for exact substring */
/* -------------------------- */
char *ct_at_exact_forward( char *pcString, size_t sStrLen,
char *pcMatch, size_t sMatchLen, size_t * psMatchStrLen )
{
size_t sPos;
HB_TRACE( HB_TR_DEBUG, ( "ct_at_exact_forward (\"%s\", %u, \"%s\", %u, %p)",
pcString, sStrLen, pcMatch, sMatchLen, psMatchStrLen ) );
if( ( sMatchLen == 0 ) || ( sStrLen < sMatchLen ) )
return NULL;
sPos = hb_strAt( pcMatch, sMatchLen, pcString, sStrLen );
if( sPos == 0 )
{
return NULL;
}
else
{
if( psMatchStrLen != NULL )
*psMatchStrLen = sMatchLen;
return pcString + sPos - 1;
}
}
| ctstr.c | 75 |
CHAR | ct_at_exact_backward( char *pcString, size_t sStrLen, char *pcMatch, size_t sMatchLen, size_t * psMatchStrLen )
/* search for exact substring in backward direction */
/* ------------------------------------------------ */
char *ct_at_exact_backward( char *pcString, size_t sStrLen,
char *pcMatch, size_t sMatchLen, size_t * psMatchStrLen )
{
size_t sIndex;
char *pcRet;
HB_TRACE( HB_TR_DEBUG, ( "ct_at_exact_backward (\"%s\", %u, \"%s\", %u, %p)",
pcString, sStrLen, pcMatch, sMatchLen, psMatchStrLen ) );
if( ( sMatchLen == 0 ) || ( sStrLen < sMatchLen ) )
return NULL;
for( pcRet = pcString + sStrLen - sMatchLen; pcRet >= pcString; pcRet-- )
{
for( sIndex = 0; sIndex < sMatchLen; sIndex++ )
if( *( pcRet + sIndex ) != *( pcMatch + sIndex ) )
break;
if( sIndex == sMatchLen )
{
/* last match found */
if( psMatchStrLen != NULL )
*psMatchStrLen = sMatchLen;
return pcRet;
}
}
return NULL;
}
| ctstr.c | 105 |
CHAR | ct_at_wildcard_forward( char *pcString, size_t sStrLen, char *pcMatch, size_t sMatchLen, char cWildCard, size_t * psMatchStrLen )
/* search for substring using wildcard */
/* ----------------------------------- */
char *ct_at_wildcard_forward( char *pcString, size_t sStrLen,
char *pcMatch, size_t sMatchLen,
char cWildCard, size_t * psMatchStrLen )
{
size_t sIndex;
char *pcRet, *pcStop;
HB_TRACE( HB_TR_DEBUG, ( "ct_at_wildcard_forward (\"%s\", %u, \"%s\", %u, \'%c\', %p)",
pcString, sStrLen, pcMatch, sMatchLen, cWildCard, psMatchStrLen ) );
if( ( sMatchLen == 0 ) || ( sStrLen < sMatchLen ) )
return NULL;
pcStop = pcString + sStrLen - sMatchLen;
for( pcRet = pcString; pcRet < pcStop; pcRet++ )
{
for( sIndex = 0; sIndex < sMatchLen; sIndex++ )
{
char c = *( pcMatch + sIndex );
if( ( c != cWildCard ) && ( c != *( pcRet + sIndex ) ) )
break;
}
if( sIndex == sMatchLen )
{
if( psMatchStrLen != NULL )
*psMatchStrLen = sMatchLen;
return pcRet;
}
}
return NULL;
}
| ctstr.c | 139 |
CHAR | ct_at_wildcard_backward( char *pcString, size_t sStrLen, char *pcMatch, size_t sMatchLen, char cWildCard, size_t * psMatchStrLen )
/* search for substring using wildcard in backward direction */
/* --------------------------------------------------------- */
char *ct_at_wildcard_backward( char *pcString, size_t sStrLen,
char *pcMatch, size_t sMatchLen,
char cWildCard, size_t * psMatchStrLen )
{
size_t sIndex;
char *pcRet;
HB_TRACE( HB_TR_DEBUG, ( "ct_at_wildcard_backward (\"%s\", %u, \"%s\", %u, \'%c\', %p)",
pcString, sStrLen, pcMatch, sMatchLen, cWildCard, psMatchStrLen ) );
if( ( sMatchLen == 0 ) || ( sStrLen < sMatchLen ) )
return NULL;
for( pcRet = pcString + sStrLen - sMatchLen; pcRet >= pcString; pcRet-- )
{
for( sIndex = 0; sIndex < sMatchLen; sIndex++ )
{
char c = *( pcMatch + sIndex );
if( ( c != cWildCard ) && ( c != *( pcRet + sIndex ) ) )
break;
}
if( sIndex == sMatchLen )
{
/* last match found */
if( psMatchStrLen != NULL )
*psMatchStrLen = sMatchLen;
return pcRet;
}
}
return NULL;
}
| ctstr.c | 178 |
CHAR | ct_at_charset_forward( char *pcString, size_t sStrLen, char *pcCharSet, size_t sCharSetLen, size_t * psMatchedCharPos )
/* search for character from a set */
/* ------------------------------- */
char *ct_at_charset_forward( char *pcString, size_t sStrLen,
char *pcCharSet, size_t sCharSetLen, size_t * psMatchedCharPos )
{
char *pcRet, *pcSet, *pcStop1, *pcStop2;
HB_TRACE( HB_TR_DEBUG, ( "ct_at_charset_forward (\"%s\", %u, \"%s\", %u, %p)",
pcString, sStrLen, pcCharSet, sCharSetLen, psMatchedCharPos ) );
*( psMatchedCharPos ) = sCharSetLen;
if( ( sCharSetLen == 0 ) || ( sStrLen == 0 ) )
return NULL;
pcStop1 = pcString + sStrLen;
pcStop2 = pcCharSet + sCharSetLen;
for( pcRet = pcString; pcRet < pcStop1; pcRet++ )
{
for( pcSet = pcCharSet; pcSet < pcStop2; pcSet++ )
if( *pcSet == *pcRet )
{
if( psMatchedCharPos != NULL )
*( psMatchedCharPos ) = pcSet - pcCharSet;
return pcRet;
}
}
return NULL;
}
| ctstr.c | 217 |
CHAR | ct_at_charset_backward( char *pcString, size_t sStrLen, char *pcCharSet, size_t sCharSetLen, size_t * psMatchedCharPos )
/* search for character from a set in backward direction */
/* ----------------------------------------------------- */
char *ct_at_charset_backward( char *pcString, size_t sStrLen,
char *pcCharSet, size_t sCharSetLen, size_t * psMatchedCharPos )
{
char *pcRet, *pcSet, *pcStop;
HB_TRACE( HB_TR_DEBUG, ( "ct_at_charset_backward (\"%s\", %u, \"%s\", %u, %p)",
pcString, sStrLen, pcCharSet, sCharSetLen, psMatchedCharPos ) );
*( psMatchedCharPos ) = sCharSetLen;
if( ( sCharSetLen == 0 ) || ( sStrLen == 0 ) )
return NULL;
pcStop = pcCharSet + sCharSetLen;
for( pcRet = pcString + sStrLen - 1; pcRet >= pcString; pcRet-- )
{
for( pcSet = pcCharSet; pcSet < pcStop; pcSet++ )
if( *pcSet == *pcRet )
{
if( psMatchedCharPos != NULL )
*( psMatchedCharPos ) = pcSet - pcCharSet;
return pcRet;
}
}
return NULL;
}
/*
* CSETREF() stuff
*/
static int siRefSwitch = 0; /* TODO: make this tread safe */
| ctstr.c | 251 |
VOID | ct_setref( int iNewSwitch )
void ct_setref( int iNewSwitch )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_setref(%i)", iNewSwitch ) );
siRefSwitch = iNewSwitch;
}
| ctstr.c | 290 |
INT | ct_getref( void )
int ct_getref( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_getref()" ) );
return siRefSwitch;
}
| ctstr.c | 297 |
HB_FUNC | CSETREF(void)
HB_FUNC( CSETREF )
{
hb_retl( ct_getref() );
if( ISLOG( 1 ) )
{
ct_setref( hb_parl( 1 ) );
}
else if( hb_pcount() > 0 ) /* 1 params, but is not logical ! */
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CSETREF,
NULL, "CSETREF", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
}
}
/*
* CSETATMUPA() stuff
*/
static int siAtMupaSwitch = 0; /* TODO: make this tread safe */
| ctstr.c | 364 |
VOID | ct_setatmupa( int iNewSwitch )
void ct_setatmupa( int iNewSwitch )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_setatmupa(%i)", iNewSwitch ) );
siAtMupaSwitch = iNewSwitch;
}
| ctstr.c | 391 |
INT | ct_getatmupa( void )
int ct_getatmupa( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_getatmupa()" ) );
return siAtMupaSwitch;
}
| ctstr.c | 398 |
HB_FUNC | CSETATMUPA(void)
HB_FUNC( CSETATMUPA )
{
hb_retl( ct_getatmupa() );
if( ISLOG( 1 ) )
{
ct_setatmupa( hb_parl( 1 ) );
}
else if( hb_pcount() > 0 ) /* 1 params, but is not logical ! */
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_CSETATMUPA, NULL,
"CSETATMUPA", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
}
}
/*
* SETATLIKE() stuff
*/
static int siAtLikeMode = 0; /* TODO: make this tread safe */
static int scAtLikeChar = '?'; /* TODO: make this tread safe */
| ctstr.c | 448 |
VOID | ct_setatlike( int iNewMode )
void ct_setatlike( int iNewMode )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_setatlike(%i)", iNewMode ) );
siAtLikeMode = iNewMode;
}
| ctstr.c | 476 |
INT | ct_getatlike( void )
int ct_getatlike( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_getatlike()" ) );
return siAtLikeMode;
}
| ctstr.c | 483 |
VOID | ct_setatlikechar( char cNewChar )
void ct_setatlikechar( char cNewChar )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_setatlikechar(\'%c\')", cNewChar ) );
scAtLikeChar = cNewChar;
}
| ctstr.c | 490 |
CHAR | ct_getatlikechar( void )
char ct_getatlikechar( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_getatlikechar()" ) );
return scAtLikeChar;
}
| ctstr.c | 497 |
HB_FUNC | SETATLIKE(void)
HB_FUNC( SETATLIKE )
{
hb_retni( ct_getatlike() );
/* set new mode if first parameter is CT_SETATLIKE_EXACT (==0)
or CT_SETATLIKE_WILDCARD (==1) */
if( ISNUM( 1 ) )
{
int iNewMode = hb_parni( 1 );
if( ( iNewMode == CT_SETATLIKE_EXACT ) || ( iNewMode == CT_SETATLIKE_WILDCARD ) )
{
ct_setatlike( iNewMode );
}
else
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_SETATLIKE,
NULL, "SETATLIKE", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
}
}
/* set new wildcard character, if ISCHAR(2) but !ISBYREF(2) */
if( ISCHAR( 2 ) )
{
if( ISBYREF( 2 ) )
{
/* new behaviour: store the current wildcard char in second parameter */
char cResult;
cResult = ct_getatlikechar();
hb_storclen( &cResult, 1, 2 );
}
else
{
char *pcNewChar = hb_parc( 2 );
if( hb_parclen( 2 ) > 0 )
ct_setatlikechar( *pcNewChar );
}
}
else if( hb_pcount() > 1 ) /* more than 2 params, but second is not string ! */
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_SETATLIKE, NULL,
"SETATLIKE", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
}
}
| ctstr.c | 563 |
ctstrfil.c |
Type | Function | Source | Line |
VOID | ct_setfcreate( int iFileAttr )
void ct_setfcreate( int iFileAttr )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_setfcreate(%i)", iFileAttr ) );
s_iFileAttr = iFileAttr;
}
| ctstrfil.c | 63 |
INT | ct_getfcreate( void )
int ct_getfcreate( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_getfcreate()" ) );
return s_iFileAttr;
}
| ctstrfil.c | 69 |
HB_FUNC | SETFCREATE(void)
HB_FUNC( SETFCREATE )
{
hb_retni( ct_getfcreate() );
if( ISNUM( 1 ) )
{
ct_setfcreate( hb_parni( 1 ) );
}
}
| ctstrfil.c | 75 |
VOID | ct_setsafety( BOOL bSafety )
void ct_setsafety( BOOL bSafety )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_setsafety(%i)", bSafety ) );
s_bSafety = bSafety;
}
| ctstrfil.c | 85 |
BOOL | ct_getsafety( void )
BOOL ct_getsafety( void )
{
HB_TRACE( HB_TR_DEBUG, ( "ct_getsafety()" ) );
return s_bSafety;
}
| ctstrfil.c | 91 |
HB_FUNC | CSETSAFETY(void)
HB_FUNC( CSETSAFETY )
{
hb_retni( ct_getsafety() );
if( ISLOG( 1 ) )
{
ct_setsafety( hb_parnl( 1 ) );
}
}
| ctstrfil.c | 97 |
STATIC LONG | ct_StrFile( BYTE * pFileName, BYTE * pcStr, ULONG ulLen, BOOL bOverwrite, LONG lOffset, BOOL bTrunc )
static LONG ct_StrFile( BYTE * pFileName, BYTE * pcStr, ULONG ulLen, BOOL bOverwrite, LONG lOffset,
BOOL bTrunc )
{
FHANDLE hFile;
BOOL bOpen = FALSE;
BOOL bFile = hb_fsFile( pFileName );
ULONG ulWrite = 0;
if( bFile && bOverwrite )
{
hFile = hb_fsOpen( pFileName, FO_READWRITE );
bOpen = TRUE;
}
else if( !bFile || !ct_getsafety() )
{
hFile = hb_fsCreate( pFileName, ct_getfcreate() );
}
else
{
hFile = FS_ERROR;
}
if( hFile != FS_ERROR )
{
if( lOffset )
hb_fsSeek( hFile, lOffset, FS_SET );
else if( bOpen )
hb_fsSeek( hFile, 0, FS_END );
ulWrite = hb_fsWriteLarge( hFile, pcStr, ulLen );
if( ( ulWrite == ulLen ) && bOpen && bTrunc )
hb_fsWrite( hFile, NULL, 0 );
hb_fsClose( hFile );
}
return ulWrite;
}
| ctstrfil.c | 107 |
HB_FUNC | STRFILE(void)
HB_FUNC( STRFILE )
{
if( ISCHAR( 1 ) && ISCHAR( 2 ) )
{
hb_retnl( ct_StrFile( ( BYTE * ) hb_parc( 2 ), ( BYTE * ) hb_parc( 1 ),
hb_parclen( 1 ), ISLOG( 3 ) && hb_parl( 3 ),
hb_parnl( 4 ), ISLOG( 5 ) && hb_parl( 5 ) ) );
}
else
{
hb_retni( 0 );
}
}
| ctstrfil.c | 145 |
HB_FUNC | FILESTR(void)
HB_FUNC( FILESTR )
{
if( ISCHAR( 1 ) )
{
FHANDLE hFile = hb_fsOpen( ( BYTE * ) hb_parc( 1 ), FO_READ );
if( hFile != FS_ERROR )
{
LONG lFileSize = hb_fsSeek( hFile, 0, FS_END );
LONG lPos = hb_fsSeek( hFile, hb_parnl( 3 ), FS_SET ), lLength;
char *pcResult, *pCtrlZ;
BOOL bCtrlZ = ISLOG( 4 ) && hb_parl( 4 );
if( ISNUM( 2 ) )
{
lLength = hb_parnl( 2 );
if( lLength > lFileSize - lPos )
lLength = lFileSize - lPos;
}
else
lLength = lFileSize - lPos;
pcResult = ( char * ) hb_xgrab( lLength + 1 );
if( lLength > 0 )
{
lLength = hb_fsReadLarge( hFile, ( BYTE * ) pcResult, ( ULONG ) lLength );
}
if( bCtrlZ )
{
pCtrlZ = ( char * ) memchr( pcResult, 26, lLength );
if( pCtrlZ )
lLength = pCtrlZ - pcResult;
}
hb_fsClose( hFile );
hb_retclen_buffer( pcResult, lLength );
}
else
{
hb_retc( NULL );
}
}
else
{
hb_retc( NULL );
}
}
| ctstrfil.c | 159 |
HB_FUNC | SCREENFILE(void)
HB_FUNC( SCREENFILE )
{
if( ISCHAR( 1 ) )
{
char *pBuffer;
ULONG ulSize;
hb_gtRectSize( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), &ulSize );
pBuffer = ( char * ) hb_xgrab( ulSize );
hb_gtSave( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), pBuffer );
hb_retnl( ct_StrFile( ( BYTE * ) hb_parc( 1 ), ( BYTE * ) pBuffer,
ulSize, ISLOG( 2 ) && hb_parl( 2 ), hb_parnl( 3 ),
ISLOG( 4 ) && hb_parl( 4 ) ) );
hb_xfree( pBuffer );
}
else
{
hb_retni( 0 );
}
}
| ctstrfil.c | 208 |
HB_FUNC | FILESCREEN(void)
HB_FUNC( FILESCREEN )
{
if( ISCHAR( 1 ) )
{
FHANDLE hFile = hb_fsOpen( ( BYTE * ) hb_parc( 1 ), FO_READ );
if( hFile != FS_ERROR )
{
char *pBuffer;
ULONG ulSize;
LONG lLength;
if( ISNUM( 2 ) )
{
hb_fsSeek( hFile, hb_parnl( 2 ), FS_SET );
}
hb_gtRectSize( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), &ulSize );
pBuffer = ( char * ) hb_xgrab( ulSize );
lLength = hb_fsReadLarge( hFile, ( BYTE * ) pBuffer, ulSize );
hb_gtRest( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), pBuffer );
hb_xfree( pBuffer );
hb_fsClose( hFile );
hb_retnl( lLength );
}
else
{
hb_retni( 0 );
}
}
else
{
hb_retni( 0 );
}
}
| ctstrfil.c | 231 |
ctwfunc.c |
Type | Function | Source | Line |
STATIC INT | hb_ctColorParam( int iParam, int iDefault )
static int hb_ctColorParam( int iParam, int iDefault )
{
int iColor;
if( ISNUM( iParam ) )
iColor = hb_parni( iParam );
else if( hb_parclen( iParam ) > 0 )
{
iColor = hb_gtColorToN( hb_parc( iParam ) );
if( iColor == -1 )
iColor = iDefault;
}
else
iColor = iDefault;
return iColor;
}
| ctwfunc.c | 57 |
HB_FUNC | CTWINIT(void)
HB_FUNC( CTWINIT )
{
hb_retl( hb_ctwInit() );
}
| ctwfunc.c | 76 |
HB_FUNC | GETCLEARA(void)
HB_FUNC( GETCLEARA )
{
hb_retni( hb_gtGetClearColor() );
}
| ctwfunc.c | 81 |
HB_FUNC | SETCLEARA(void)
HB_FUNC( SETCLEARA )
{
int iColor = hb_ctColorParam( 1, -1 );
if( iColor >= 0 )
hb_gtSetClearColor( iColor & 0xff );
hb_retc( NULL );
}
| ctwfunc.c | 86 |
HB_FUNC | SETCLEARB(void)
HB_FUNC( SETCLEARB )
{
int iNew;
if( ISNUM( 1 ) )
iNew = hb_parni( 1 );
else if( ISCHAR( 1 ) )
iNew = hb_parc( 1 )[0];
else
iNew = 255;
hb_gtSetClearChar( iNew & 0xff );
hb_retc( NULL );
}
| ctwfunc.c | 96 |
HB_FUNC | GETCLEARB(void)
HB_FUNC( GETCLEARB )
{
hb_retni( hb_gtGetClearChar() );
}
| ctwfunc.c | 112 |
HB_FUNC | WSETSHADOW(void)
HB_FUNC( WSETSHADOW )
{
hb_retni( hb_ctwSetShadowAttr( hb_ctColorParam( 1, -2 ) ) );
}
| ctwfunc.c | 117 |
HB_FUNC | WSETMOVE(void)
HB_FUNC( WSETMOVE )
{
hb_retl( hb_ctwSetMoveMode( ISLOG( 1 ) ? hb_parl( 1 ) : -1 ) != 0 );
}
| ctwfunc.c | 122 |
HB_FUNC | WSTEP(void)
HB_FUNC( WSTEP )
{
if( ISNUM( 1 ) && ISNUM( 2 ) )
hb_retni( hb_ctwSetMoveStep( hb_parni( 1 ), hb_parni( 2 ) ) );
else
hb_retni( -1 );
}
| ctwfunc.c | 127 |
HB_FUNC | WMODE(void)
HB_FUNC( WMODE )
{
hb_retni( hb_ctwSetBorderMode( ISLOG( 1 ) ? ( hb_parl( 1 ) ? 1 : 0 ) : -1,
ISLOG( 2 ) ? ( hb_parl( 2 ) ? 1 : 0 ) : -1,
ISLOG( 3 ) ? ( hb_parl( 3 ) ? 1 : 0 ) : -1,
ISLOG( 4 ) ? ( hb_parl( 4 ) ? 1 : 0 ) : -1 ) );
}
| ctwfunc.c | 135 |
HB_FUNC | WBOARD(void)
HB_FUNC( WBOARD )
{
hb_retni( hb_ctwSetWindowBoard( hb_parni( 1 ), hb_parni( 2 ),
ISNUM( 3 ) ? hb_parni( 3 ) : hb_gtMaxRow(),
ISNUM( 4 ) ? hb_parni( 4 ) : hb_gtMaxCol() ) );
}
| ctwfunc.c | 143 |
HB_FUNC | WOPEN(void)
HB_FUNC( WOPEN )
{
int iColor;
iColor = hb_ctColorParam( 6, 0 ); /* Harbour extension */
hb_retni( hb_ctwCreateWindow( hb_parni( 1 ), hb_parni( 2 ),
hb_parni( 3 ), hb_parni( 4 ),
hb_parl( 5 ), iColor ) );
}
| ctwfunc.c | 150 |
HB_FUNC | WCLOSE(void)
HB_FUNC( WCLOSE )
{
hb_retni( hb_ctwCloseWindow( hb_ctwCurrentWindow() ) );
}
| ctwfunc.c | 160 |
HB_FUNC | WACLOSE(void)
HB_FUNC( WACLOSE )
{
hb_retni( hb_ctwCloseAllWindows() );
}
| ctwfunc.c | 165 |
HB_FUNC | WSELECT(void)
HB_FUNC( WSELECT )
{
hb_retni( ISNUM( 1 ) ? hb_ctwSelectWindow( hb_parni( 1 ) ) :
hb_ctwCurrentWindow() );
}
| ctwfunc.c | 170 |
HB_FUNC | WNUM(void)
HB_FUNC( WNUM )
{
hb_retni( hb_ctwMaxWindow() );
}
| ctwfunc.c | 176 |
HB_FUNC | WBOX(void)
HB_FUNC( WBOX )
{
static const char * pWBoxFrames[] = {
_B_DOUBLE, /* 0 WB_DOUBLE_CLEAR */
_B_SINGLE, /* 1 WB_SINGLE_CLEAR */
_B_DOUBLE_SINGLE, /* 2 WB_DOUBLE_SINGLE_CLEAR */
_B_SINGLE_DOUBLE, /* 3 WB_SINGLE_DOUBLE_CLEAR */
_B_DOUBLE, /* 4 WB_DOUBLE */
_B_SINGLE, /* 5 WB_SINGLE */
_B_DOUBLE_SINGLE, /* 6 WB_DOUBLE_SINGLE */
_B_SINGLE_DOUBLE, /* 7 WB_SINGLE_DOUBLE */
"ÛßÛÛÛÜÛÛ", /* 8 WB_HALF_FULL_CLEAR */
"ÞßÝÝÝÜÞÞ", /* 9 WB_HALF_CLEAR */
"ÞÛÝÝÝÛÞÞ", /* 10 WB_FULL_HALF_CLEAR */
"ÛÛÛÛÛÛÛÛ", /* 11 WB_FULL_CLEAR */
"ÛßÛÛÛÜÛÛ", /* 12 WB_HALF_FULL */
"ÞßÝÝÝÜÞÞ", /* 13 WB_HALF */
"ÞÛÝÝÝÛÞÞ", /* 14 WB_FULL_HALF */
"ÛÛÛÛÛÛÛÛ" }; /* 15 WB_FULL */
BYTE * szBox, szBoxBuf[ 10 ];
int iColor;
if( ISCHAR( 1 ) )
{
szBox = ( BYTE * ) hb_parc( 1 );
}
else
{
int iFrame = hb_parni( 1 );
if( iFrame < 0 || iFrame > 15 )
iFrame = 0;
memcpy( szBoxBuf, pWBoxFrames[ iFrame ], 9 );
if( ( iFrame & 4 ) == 0 )
{
szBoxBuf[ 8 ] = hb_gtGetClearChar();
}
szBoxBuf[ 9 ] = '0';
szBox = szBoxBuf;
}
iColor = hb_ctColorParam( 2, 0 ); /* Harbour extension */
hb_retni( hb_ctwAddWindowBox( hb_ctwCurrentWindow(), szBox, iColor ) );
}
| ctwfunc.c | 181 |
HB_FUNC | WFORMAT(void)
HB_FUNC( WFORMAT )
{
int iWindow = hb_ctwCurrentWindow();
int iTop, iLeft, iBottom, iRight;
if( hb_pcount() == 0 )
{
hb_ctwGetFormatCords( iWindow, TRUE, &iTop, &iLeft, &iBottom, &iRight );
iTop = -iTop;
iLeft = -iLeft;
iBottom = -iBottom;
iRight = -iRight;
}
else
{
iTop = hb_parni( 1 );
iLeft = hb_parni( 2 );
iBottom = hb_parni( 3 );
iRight = hb_parni( 4 );
}
hb_retni( hb_ctwChangeMargins( iWindow, iTop, iLeft, iBottom, iRight ) );
}
| ctwfunc.c | 230 |
HB_FUNC | WROW(void)
HB_FUNC( WROW )
{
int iTop, iLeft, iBottom, iRight;
hb_ctwGetWindowCords( hb_ctwCurrentWindow(), hb_parl( 1 ), &iTop, &iLeft, &iBottom, &iRight );
hb_retni( iTop );
}
| ctwfunc.c | 253 |
HB_FUNC | WCOL(void)
HB_FUNC( WCOL )
{
int iTop, iLeft, iBottom, iRight;
hb_ctwGetWindowCords( hb_ctwCurrentWindow(), hb_parl( 1 ), &iTop, &iLeft, &iBottom, &iRight );
hb_retni( iLeft );
}
| ctwfunc.c | 261 |
HB_FUNC | WLASTROW(void)
HB_FUNC( WLASTROW )
{
int iTop, iLeft, iBottom, iRight;
hb_ctwGetWindowCords( hb_ctwCurrentWindow(), hb_parl( 1 ), &iTop, &iLeft, &iBottom, &iRight );
hb_retni( iBottom );
}
| ctwfunc.c | 269 |
HB_FUNC | WLASTCOL(void)
HB_FUNC( WLASTCOL )
{
int iTop, iLeft, iBottom, iRight;
hb_ctwGetWindowCords( hb_ctwCurrentWindow(), hb_parl( 1 ), &iTop, &iLeft, &iBottom, &iRight );
hb_retni( iRight );
}
| ctwfunc.c | 277 |
HB_FUNC | WFROW(void)
HB_FUNC( WFROW )
{
int iTop, iLeft, iBottom, iRight;
hb_ctwGetFormatCords( hb_ctwCurrentWindow(), hb_parl( 1 ), &iTop, &iLeft, &iBottom, &iRight );
hb_retni( iTop );
}
| ctwfunc.c | 285 |
HB_FUNC | WFCOL(void)
HB_FUNC( WFCOL )
{
int iTop, iLeft, iBottom, iRight;
hb_ctwGetFormatCords( hb_ctwCurrentWindow(), hb_parl( 1 ), &iTop, &iLeft, &iBottom, &iRight );
hb_retni( iLeft );
}
| ctwfunc.c | 293 |
HB_FUNC | WFLASTROW(void)
HB_FUNC( WFLASTROW )
{
int iTop, iLeft, iBottom, iRight;
hb_ctwGetFormatCords( hb_ctwCurrentWindow(), hb_parl( 1 ), &iTop, &iLeft, &iBottom, &iRight );
hb_retni( iBottom );
}
| ctwfunc.c | 301 |
HB_FUNC | WFLASTCOL(void)
HB_FUNC( WFLASTCOL )
{
int iTop, iLeft, iBottom, iRight;
hb_ctwGetFormatCords( hb_ctwCurrentWindow(), hb_parl( 1 ), &iTop, &iLeft, &iBottom, &iRight );
hb_retni( iRight );
}
| ctwfunc.c | 309 |
HB_FUNC | WCENTER(void)
HB_FUNC( WCENTER )
{
hb_retni( hb_ctwCenterWindow( hb_ctwCurrentWindow(), hb_parl( 1 ) ) );
}
| ctwfunc.c | 317 |
HB_FUNC | WMOVE(void)
HB_FUNC( WMOVE )
{
hb_retni( hb_ctwMoveWindow( hb_ctwCurrentWindow(),
hb_parni( 1 ), hb_parni( 2 ) ) );
}
| ctwfunc.c | 322 |
HB_FUNC | CTWLASTKEY(void)
HB_FUNC( CTWLASTKEY )
{
hb_retni( hb_ctwLastKey() );
}
| ctwfunc.c | 328 |
HB_FUNC | HBCT_MAXROW(void)
HB_FUNC( HBCT_MAXROW ) /* Return the maximum screen/window row number (zero origin) */
{
if( ISLOG( 1 ) && hb_parl( 1 ) )
{
USHORT uiRows, uiCols;
hb_gtScrDim( &uiRows, &uiCols );
hb_retni( uiRows - 1 );
}
else
hb_retni( hb_gtMaxRow() );
}
| ctwfunc.c | 336 |
HB_FUNC | HBCT_MAXCOL(void)
HB_FUNC( HBCT_MAXCOL ) /* Return the maximum screen/window column number (zero origin) */
{
if( ISLOG( 1 ) && hb_parl( 1 ) )
{
USHORT uiRows, uiCols;
hb_gtScrDim( &uiRows, &uiCols );
hb_retni( uiCols - 1 );
}
else
hb_retni( hb_gtMaxCol() );
}
| ctwfunc.c | 348 |
ctwin.c |
Type | Function | Source | Line |
STATIC INT | hb_ctw_CalcShadowWidth( int iRows, int iCols )
static int hb_ctw_CalcShadowWidth( int iRows, int iCols )
{
if( iRows + iRows >= iCols )
return 1;
else
return 2;
}
| ctwin.c | 140 |
STATIC VOID | hb_ctw_SetMap( PHB_GT pGT, int * piMap, int iWindow, int iTop, int iLeft, int iBottom, int iRight )
static void hb_ctw_SetMap( PHB_GT pGT, int * piMap, int iWindow, int iTop, int iLeft, int iBottom, int iRight )
{
ULONG lIndex;
int i;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_SetMap(%p,%p,%d,%d,%d,%d,%d)", pGT, piMap, iWindow, iTop, iLeft, iBottom, iRight));
HB_SYMBOL_UNUSED( pGT );
if( iTop < 0 )
iTop = 0;
if( iBottom >= s_iMapHeight )
iBottom = s_iMapHeight - 1;
if( iLeft < 0 )
iLeft = 0;
if( iRight >= s_iMapWidth )
iRight = s_iMapWidth - 1;
while( iTop <= iBottom )
{
lIndex = iTop * s_iMapWidth + iLeft;
for( i = iLeft; i <= iRight; ++i, ++lIndex )
piMap[ lIndex ] = iWindow;
++iTop;
}
}
| ctwin.c | 148 |
STATIC VOID | hb_ctw_ClearMap( PHB_GT pGT )
static void hb_ctw_ClearMap( PHB_GT pGT )
{
ULONG ulSize;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_ClearMap(%p)", pGT));
HB_SYMBOL_UNUSED( pGT );
ulSize = ( ULONG ) s_iMapHeight * s_iMapWidth * sizeof( int );
memset( s_pWindowMap, 0, ulSize );
memset( s_pShadowMap, 0, ulSize );
}
| ctwin.c | 175 |
STATIC VOID | hb_ctw_WindowMap( PHB_GT pGT, int iWindow, BOOL fExpose )
static void hb_ctw_WindowMap( PHB_GT pGT, int iWindow, BOOL fExpose )
{
PHB_CT_WND pWnd;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_WindowMap(%p,%d,%d)", pGT, iWindow, (int) fExpose));
pWnd = s_windows[ iWindow ];
if( ! pWnd->fHidden )
{
int iLastRow = pWnd->iFirstRow + pWnd->iHeight - 1,
iLastCol = pWnd->iFirstCol + pWnd->iWidth - 1;
hb_ctw_SetMap( pGT, s_pWindowMap, iWindow,
pWnd->iFirstRow, pWnd->iFirstCol,
iLastRow, iLastCol );
hb_ctw_SetMap( pGT, s_pShadowMap, 0,
pWnd->iFirstRow, pWnd->iFirstCol,
iLastRow, iLastCol );
if( pWnd->iShadowAttr >= 0 &&
iLastRow >= s_iBoardTop && iLastCol >= s_iBoardLeft &&
pWnd->iFirstRow <= s_iBoardBottom && pWnd->iFirstCol <= s_iBoardRight )
{
iLastRow += 1;
iLastCol += s_iShadowWidth;
hb_ctw_SetMap( pGT, s_pShadowMap, iWindow,
iLastRow, pWnd->iFirstCol + s_iShadowWidth,
iLastRow, iLastCol );
hb_ctw_SetMap( pGT, s_pShadowMap, iWindow,
pWnd->iFirstRow + 1, pWnd->iFirstCol + pWnd->iWidth,
iLastRow - 1, iLastCol );
}
if( fExpose )
{
HB_GTSUPER_EXPOSEAREA( pGT, pWnd->iFirstRow, pWnd->iFirstCol,
iLastRow, iLastCol );
}
}
}
| ctwin.c | 188 |
STATIC VOID | hb_ctw_RemapAllWindows( PHB_GT pGT )
static void hb_ctw_RemapAllWindows( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_RemapAllWindows(%p)", pGT));
if( s_iMaxWindow )
{
int i;
hb_ctw_ClearMap( pGT );
for( i = 0; i < s_iOpenWindows; ++i )
hb_ctw_WindowMap( pGT, s_windowStack[ i ], FALSE );
HB_GTSUPER_EXPOSEAREA( pGT, 0, 0, s_iMapHeight, s_iMapWidth );
}
}
| ctwin.c | 228 |
STATIC BOOL | hb_ctw_Init( PHB_GT pGT )
static BOOL hb_ctw_Init( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_Init(%p)",pGT));
if( ! s_fInit )
{
s_fInit = hb_gtLoad( HB_GT_DRVNAME( HB_GT_NAME ), NULL );
if( s_fInit )
{
int iRow, iCol;
HB_GTSUPER_GETSIZE( pGT, &s_iMapHeight, &s_iMapWidth );
/* update cursor position to the rules used by CTWIN */
HB_GTSELF_GETPOS( pGT, &iRow, &iCol );
HB_GTSELF_SETPOS( pGT, iRow, iCol );
}
}
return s_fInit;
}
| ctwin.c | 243 |
STATIC INT | hb_ctw_SetShadowAttr( PHB_GT pGT, int iAttr )
static int hb_ctw_SetShadowAttr( PHB_GT pGT, int iAttr )
{
int iOldAttr = s_iShadowAttr;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_SetShadowAttr(%p,%d)", pGT, iAttr));
HB_SYMBOL_UNUSED( pGT );
if( iAttr >= -1 )
s_iShadowAttr = iAttr;
return iOldAttr;
}
| ctwin.c | 265 |
STATIC INT | hb_ctw_SetMoveMode( PHB_GT pGT, int iMode )
static int hb_ctw_SetMoveMode( PHB_GT pGT, int iMode )
{
int iOldMode = s_iMoveMode;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_SetMoveMode(%p,%d)", pGT, iMode));
HB_SYMBOL_UNUSED( pGT );
if( iMode >= 0 )
s_iMoveMode = iMode;
return iOldMode;
}
| ctwin.c | 279 |
STATIC INT | hb_ctw_SetMoveStep( PHB_GT pGT, int iVertical, int iHorizontal )
static int hb_ctw_SetMoveStep( PHB_GT pGT, int iVertical, int iHorizontal )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_SetMoveStep(%p,%d,%d)", pGT, iVertical, iHorizontal));
if( s_fInit || hb_ctw_Init( pGT ) )
{
if( iVertical < s_iMapHeight && iHorizontal < s_iMapWidth )
{
s_iVerticalStep = iVertical;
s_iHorizontalStep = iHorizontal;
return 0;
}
}
return -1;
}
| ctwin.c | 293 |
STATIC INT | hb_ctw_SetWindowBoard( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
static int hb_ctw_SetWindowBoard( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_SetWindowBoard(%d,%d,%d,%d)", iTop, iLeft, iBottom, iRight));
if( s_fInit || hb_ctw_Init( pGT ) )
{
/*
* This limitation is only for strict CT3 compatibility, the CTW GTs
* can work in practice with any virtual board size and position and
* is limited only by available physical memory, [druzus]
*/
if( iBottom >= s_iMapHeight )
iBottom = s_iMapHeight - 1;
if( iRight >= s_iMapWidth )
iRight = s_iMapWidth - 1;
if( iTop >= 0 && iLeft >= 0 && iTop < iBottom && iLeft < iRight )
{
s_iBoardTop = iTop;
s_iBoardLeft = iLeft;
s_iBoardBottom = iBottom;
s_iBoardRight = iRight;
s_fBoardSet = TRUE;
hb_ctw_RemapAllWindows( pGT );
return 0;
}
}
return -1;
}
| ctwin.c | 311 |
STATIC INT | hb_ctw_SetBorderMode( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
static int hb_ctw_SetBorderMode( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_SetBorderMode(%p,%d,%d,%d,%d)", pGT, iTop, iLeft, iBottom, iRight));
if( s_fInit || hb_ctw_Init( pGT ) )
{
if( iTop >= 0 )
s_fBoardTop = iTop != 0;
if( iLeft >= 0 )
s_fBoardLeft = iLeft != 0;
if( iBottom >= 0 )
s_fBoardBottom = iBottom != 0;
if( iRight >= 0 )
s_fBoardRight = iRight != 0;
return 0;
}
return -1;
}
| ctwin.c | 342 |
STATIC INT | hb_ctw_CurrentWindow( PHB_GT pGT )
static int hb_ctw_CurrentWindow( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_CurrentWindow(%p)", pGT));
HB_SYMBOL_UNUSED( pGT );
return s_iCurrWindow;
}
| ctwin.c | 363 |
STATIC INT | hb_ctw_SelectWindow( PHB_GT pGT, int iWindow )
static int hb_ctw_SelectWindow( PHB_GT pGT, int iWindow )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_SelectWindow(%p,%d)", pGT, iWindow));
if( iWindow == 0 )
s_iCurrWindow = iWindow;
else if( iWindow != s_iCurrWindow &&
iWindow > 0 && iWindow <= s_iMaxWindow &&
s_windows[ iWindow ] != NULL )
{
s_iCurrWindow = iWindow;
if( iWindow != s_windowStack[ s_iOpenWindows - 1 ] )
{
int i;
for( i = 0; i < s_iOpenWindows; ++i )
{
if( s_windowStack[ i ] == iWindow )
break;
}
while( i < s_iOpenWindows - 1 )
{
s_windowStack[ i ] = s_windowStack[ i + 1 ];
++i;
}
s_windowStack[ s_iOpenWindows - 1 ] = iWindow;
/* INFO: CT effectively calls hb_ctw_RemapAllWindows() here */
hb_ctw_WindowMap( pGT, iWindow, TRUE );
}
}
return s_iCurrWindow;
}
| ctwin.c | 372 |
STATIC INT | hb_ctw_MaxWindow( PHB_GT pGT )
static int hb_ctw_MaxWindow( PHB_GT pGT )
{
int i, iMaxHandle = 0;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_MaxWindow(%p)", pGT));
HB_SYMBOL_UNUSED( pGT );
for( i = 0; i < s_iOpenWindows; ++i )
{
if( iMaxHandle < s_windowStack[ i ] )
iMaxHandle = s_windowStack[ i ];
}
return iMaxHandle;
}
| ctwin.c | 406 |
STATIC INT | hb_ctw_CreateWindow( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BOOL fClear, int iColor )
static int hb_ctw_CreateWindow( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, BOOL fClear, int iColor )
{
PHB_CT_WND pWnd;
BYTE bAttr, bColor;
USHORT usChar;
int iRow, iCol, iHeight, iWidth, iTmp;
long lIndex;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_CreateWindow(%p,%d,%d,%d,%d,%d,%d)", pGT, iTop, iLeft, iBottom, iRight, (int) fClear, iColor));
if( s_iOpenWindows == s_iMaxWindow )
{
int i = s_iMaxWindow;
if( s_iMaxWindow == 0 )
{
ULONG ulSize;
if( !s_fInit )
{
if( ! hb_ctw_Init( pGT ) )
return -1;
}
HB_GTSUPER_GETSIZE( pGT, &s_iMapHeight, &s_iMapWidth );
s_iShadowWidth = hb_ctw_CalcShadowWidth( s_iMapHeight, s_iMapWidth );
if( !s_fBoardSet )
hb_ctw_SetWindowBoard( pGT, 0, 0, s_iMapHeight - 1, s_iMapWidth - 1 );
ulSize = ( ULONG ) s_iMapHeight * s_iMapWidth * sizeof( int );
s_pWindowMap = ( int * ) hb_xgrab( ulSize );
s_pShadowMap = ( int * ) hb_xgrab( ulSize );
hb_ctw_ClearMap( pGT );
s_iMaxWindow = HB_CTWIN_ALLOC;
s_windows = ( PHB_CT_WND * ) hb_xgrab( ( HB_CTWIN_ALLOC + 1 ) * sizeof( PHB_CT_WND ) );
s_windowStack = ( int * ) hb_xgrab( HB_CTWIN_ALLOC * sizeof( int ) );
s_windows[ 0 ] = NULL;
}
else
{
s_iMaxWindow += HB_CTWIN_ALLOC;
s_windows = ( PHB_CT_WND * ) hb_xrealloc( s_windows, ( s_iMaxWindow + 1 ) * sizeof( PHB_CT_WND ) );
s_windowStack = ( int * ) hb_xrealloc( s_windowStack, s_iMaxWindow * sizeof( int ) );
}
do
{
s_windows[ i + 1 ] = NULL;
s_windowStack[ i ] = 0;
}
while( ++i < s_iMaxWindow );
}
iHeight = iBottom - iTop + 1;
iWidth = iRight - iLeft + 1;
iRow = iTop;
iCol = iLeft;
if( iHeight > s_iBoardBottom - s_iBoardTop + 1 )
iHeight = s_iBoardBottom - s_iBoardTop + 1;
if( iWidth > s_iBoardRight - s_iBoardLeft + 1 )
iWidth = s_iBoardRight - s_iBoardLeft + 1;
if( iHeight < HB_CTWIN_MINROWS || iWidth < HB_CTWIN_MINCOLS ||
iHeight > HB_CTWIN_MAXROWS || iWidth > HB_CTWIN_MAXCOLS )
return -1;
iTop = s_iBoardTop - ( s_fBoardTop ? iHeight : 0 );
iBottom = s_iBoardBottom + 1 - ( s_fBoardBottom ? 0 : iHeight );
iLeft = s_iBoardLeft - ( s_fBoardLeft ? iWidth : 0 );
iRight = s_iBoardRight + 1 - ( s_fBoardRight ? 0 : iWidth );
if( iRow < iTop )
iRow = iTop;
else if( iRow > iBottom )
iRow = iBottom;
if( iCol < iLeft )
iCol = iLeft;
else if( iCol > iRight )
iCol = iRight;
pWnd = ( PHB_CT_WND ) hb_xgrab( sizeof( HB_CT_WND ) );
memset( pWnd, 0, sizeof( HB_CT_WND ) );
pWnd->fHidden = FALSE;
pWnd->iShadowAttr = s_iShadowAttr;
pWnd->iCursorStyle = HB_GTSELF_GETCURSORSTYLE( pGT );
pWnd->iHeight = iHeight;
pWnd->iWidth = iWidth;
pWnd->iFirstRow = iRow;
pWnd->iFirstCol = iCol;
HB_GTSELF_GETCOLORDATA( pGT, &pWnd->piColors, &pWnd->iColorCount, &pWnd->iColorIndex );
pWnd->screenBuffer = ( PHB_SCREENCELL ) hb_xgrab( ( ULONG ) pWnd->iHeight *
pWnd->iWidth * sizeof( HB_SCREENCELL ) );
if( pWnd->iShadowAttr >= 0 )
fClear = TRUE;
bAttr = 0;
bColor = iColor ? iColor : HB_GTSELF_GETCOLOR( pGT );
usChar = ( USHORT ) HB_GTSELF_GETCLEARCHAR( pGT );
lIndex = 0;
for( iRow = pWnd->iFirstRow; iRow < pWnd->iFirstRow + pWnd->iHeight; ++iRow )
{
for( iCol = pWnd->iFirstCol; iCol < pWnd->iFirstCol + pWnd->iWidth; ++iCol )
{
if( !fClear && !HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &bColor, &bAttr, &usChar ) )
{
usChar = ( USHORT ) HB_GTSELF_GETCLEARCHAR( pGT );
bColor = ( BYTE ) HB_GTSELF_GETCOLOR( pGT );
bAttr = 0;
}
pWnd->screenBuffer[ lIndex ].c.usChar = usChar;
pWnd->screenBuffer[ lIndex ].c.bColor = bColor;
pWnd->screenBuffer[ lIndex ].c.bAttr = 0;
++lIndex;
}
}
for( iTmp = 1; iTmp < s_iMaxWindow; ++iTmp )
{
if( s_windows[ iTmp ] == NULL )
break;
}
pWnd->iHandle = iTmp;
s_windows[ pWnd->iHandle ] = pWnd;
s_windowStack[ s_iOpenWindows++ ] = pWnd->iHandle;
s_iCurrWindow = pWnd->iHandle;
hb_ctw_WindowMap( pGT, pWnd->iHandle, TRUE );
return pWnd->iHandle;
}
| ctwin.c | 423 |
STATIC INT | hb_ctw_CloseWindow( PHB_GT pGT, int iWindow )
static int hb_ctw_CloseWindow( PHB_GT pGT, int iWindow )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_CloseWindow(%p,%d)", pGT, iWindow));
if( iWindow > 0 && iWindow <= s_iMaxWindow && s_windows[ iWindow ] )
{
PHB_CT_WND pWnd = s_windows[ iWindow ];
int i, iWnd, iLast;
BOOL fHidden = pWnd->fHidden;
hb_xfree( pWnd->screenBuffer );
if( pWnd->iColorCount )
hb_xfree( pWnd->piColors );
hb_xfree( pWnd );
s_windows[ iWindow ] = NULL;
iWnd = 0;
i = --s_iOpenWindows;
do
{
iLast = s_windowStack[ i ];
s_windowStack[ i ] = iWnd;
if( iLast == iWindow )
break;
iWnd = iLast;
}
while( --i >= 0 );
if( iWindow == s_iCurrWindow )
s_iCurrWindow = s_iOpenWindows > 0 ? s_windowStack[ s_iOpenWindows - 1 ] : 0;
if( !fHidden )
hb_ctw_RemapAllWindows( pGT );
return s_iCurrWindow;
}
return -1;
}
| ctwin.c | 560 |
STATIC INT | hb_ctw_CloseAllWindows( PHB_GT pGT )
static int hb_ctw_CloseAllWindows( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_CloseAllWindows(%p)", pGT));
if( s_iOpenWindows > 0 )
{
PHB_CT_WND pWnd;
int i, iWindow;
for( i = 0; i < s_iOpenWindows; ++i )
{
iWindow = s_windowStack[ i ];
pWnd = s_windows[ iWindow ];
s_windowStack[ i ] = 0;
s_windows[ iWindow ] = NULL;
hb_xfree( pWnd->screenBuffer );
if( pWnd->iColorCount )
hb_xfree( pWnd->piColors );
hb_xfree( pWnd );
}
s_iOpenWindows = s_iCurrWindow = 0;
hb_ctw_RemapAllWindows( pGT );
return 0;
}
return -1;
}
| ctwin.c | 599 |
STATIC INT | hb_ctw_CenterWindow( PHB_GT pGT, int iWindow, BOOL fCenter )
static int hb_ctw_CenterWindow( PHB_GT pGT, int iWindow, BOOL fCenter )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_CenterWindow(%p,%d,%d)", pGT, iWindow, (int) fCenter));
HB_SYMBOL_UNUSED( pGT );
if( iWindow > 0 && iWindow <= s_iOpenWindows )
{
PHB_CT_WND pWnd = s_windows[ iWindow ];
if( pWnd )
{
if( fCenter )
{
int iHeight = s_iBoardBottom - s_iBoardTop + 1,
iWidth = s_iBoardRight - s_iBoardLeft + 1;
pWnd->iFirstRow = s_iBoardTop;
pWnd->iFirstCol = s_iBoardLeft;
if( iHeight > pWnd->iHeight )
pWnd->iFirstRow += ( iHeight - pWnd->iHeight ) >> 1;
if( iWidth > pWnd->iWidth )
pWnd->iFirstCol += ( iWidth - pWnd->iWidth ) >> 1;
}
else
{
if( pWnd->iFirstRow > s_iBoardBottom - pWnd->iHeight + 1 )
pWnd->iFirstRow = s_iBoardBottom - pWnd->iHeight + 1;
if( pWnd->iFirstRow < s_iBoardTop )
pWnd->iFirstRow = s_iBoardTop;
if( pWnd->iFirstCol > s_iBoardRight - pWnd->iWidth + 1 )
pWnd->iFirstCol = s_iBoardRight - pWnd->iWidth + 1;
if( pWnd->iFirstCol < s_iBoardLeft )
pWnd->iFirstCol = s_iBoardLeft;
}
return iWindow;
}
}
return -1;
}
| ctwin.c | 627 |
STATIC INT | hb_ctw_MoveWindow( PHB_GT pGT, int iWindow, int iRow, int iCol )
static int hb_ctw_MoveWindow( PHB_GT pGT, int iWindow, int iRow, int iCol )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_MoveWindow(%p,%d,%d,%d)", pGT, iWindow, iRow, iCol));
if( iWindow > 0 && iWindow <= s_iOpenWindows )
{
PHB_CT_WND pWnd = s_windows[ iWindow ];
if( pWnd )
{
if( ( iRow + ( s_fBoardTop ? pWnd->iHeight : 0 ) >= s_iBoardTop ) &&
( iRow + ( s_fBoardBottom ? 0 : pWnd->iHeight ) <= s_iBoardBottom + 1 ) &&
( iCol + ( s_fBoardLeft ? pWnd->iWidth : 0 ) >= s_iBoardLeft ) &&
( iCol + ( s_fBoardRight ? 0 : pWnd->iWidth ) <= s_iBoardRight + 1 ) )
{
pWnd->iFirstRow = iRow;
pWnd->iFirstCol = iCol;
if( ! pWnd->fHidden )
hb_ctw_RemapAllWindows( pGT );
return iWindow;
}
}
}
return -1;
}
| ctwin.c | 670 |
STATIC INT | hb_ctw_ChangeMargins( PHB_GT pGT, int iWindow, int iTop, int iLeft, int iBottom, int iRight )
static int hb_ctw_ChangeMargins( PHB_GT pGT, int iWindow, int iTop, int iLeft, int iBottom, int iRight )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_ChangeMargins(%p,%d,%d,%d,%d,%d)", pGT, iWindow, iTop, iLeft, iBottom, iRight));
HB_SYMBOL_UNUSED( pGT );
if( iWindow > 0 && iWindow <= s_iOpenWindows )
{
PHB_CT_WND pWnd = s_windows[ iWindow ];
if( pWnd )
{
if( ( iTop += pWnd->iTopMargin ) < 0 )
iTop = 0;
if( ( iLeft += pWnd->iLeftMargin ) < 0 )
iLeft = 0;
if( ( iBottom += pWnd->iBottomMargin ) < 0 )
iBottom = 0;
if( ( iRight += pWnd->iRightMargin ) < 0 )
iRight = 0;
if( iTop + iBottom < pWnd->iHeight && iLeft + iRight < pWnd->iWidth )
{
pWnd->iTopMargin = iTop;
pWnd->iLeftMargin = iLeft;
pWnd->iBottomMargin = iBottom;
pWnd->iRightMargin = iRight;
return iWindow;
}
}
}
return -1;
}
| ctwin.c | 697 |
STATIC INT | hb_ctw_GetWindowCords( PHB_GT pGT, int iWindow, BOOL fCenter, int * piTop, int * piLeft, int * piBottom, int * piRight )
static int hb_ctw_GetWindowCords( PHB_GT pGT, int iWindow, BOOL fCenter, int * piTop, int * piLeft, int * piBottom, int * piRight )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_GetWindowCords(%p,%d,%d,%p,%p,%p,%p)", pGT, iWindow, (int) fCenter, piTop, piLeft, piBottom, piRight));
if( iWindow > 0 && iWindow <= s_iOpenWindows )
{
PHB_CT_WND pWnd = s_windows[ iWindow ];
if( pWnd )
{
if( fCenter )
{
int iHeight = s_iBoardBottom - s_iBoardTop + 1,
iWidth = s_iBoardRight - s_iBoardLeft + 1;
*piTop = s_iBoardTop;
*piLeft = s_iBoardLeft;
if( iHeight > pWnd->iHeight )
*piTop += ( iHeight - pWnd->iHeight ) >> 1;
if( iWidth > pWnd->iWidth )
*piLeft += ( iWidth - pWnd->iWidth ) >> 1;
}
else
{
*piTop = pWnd->iFirstRow;
*piLeft = pWnd->iFirstCol;
}
*piBottom = *piTop + pWnd->iHeight - 1;
*piRight = *piLeft + pWnd->iWidth - 1;
return iWindow;
}
}
*piTop = *piLeft = 0;
*piBottom = HB_GTSELF_MAXROW( pGT );
*piRight = HB_GTSELF_MAXCOL( pGT );
return -1;
}
| ctwin.c | 733 |
STATIC INT | hb_ctw_GetFormatCords( PHB_GT pGT, int iWindow, BOOL fRelative, int * piTop, int * piLeft, int * piBottom, int * piRight )
static int hb_ctw_GetFormatCords( PHB_GT pGT, int iWindow, BOOL fRelative, int * piTop, int * piLeft, int * piBottom, int * piRight )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_GetFormatCords(%p,%d,%d,%p,%p,%p,%p)", pGT, iWindow, (int) fRelative, piTop, piLeft, piBottom, piRight));
if( iWindow > 0 && iWindow <= s_iOpenWindows )
{
PHB_CT_WND pWnd = s_windows[ iWindow ];
if( pWnd )
{
if( fRelative )
{
*piTop = pWnd->iTopMargin;
*piLeft = pWnd->iLeftMargin;
*piBottom = pWnd->iBottomMargin;
*piRight = pWnd->iRightMargin;
}
else
{
*piTop = pWnd->iFirstRow + pWnd->iTopMargin;
*piLeft = pWnd->iFirstCol + pWnd->iLeftMargin;
*piBottom = pWnd->iFirstRow + pWnd->iHeight - pWnd->iBottomMargin - 1;
*piRight = pWnd->iFirstCol + pWnd->iWidth - pWnd->iRightMargin - 1;
}
return iWindow;
}
}
if( fRelative )
{
*piTop = *piLeft = *piBottom = *piRight = 0;
}
else
{
*piTop = *piLeft = 0;
*piBottom = HB_GTSELF_MAXROW( pGT );
*piRight = HB_GTSELF_MAXCOL( pGT );
}
return -1;
}
| ctwin.c | 775 |
STATIC INT | hb_ctw_AddWindowBox( PHB_GT pGT, int iWindow, BYTE * szBox, int iColor )
static int hb_ctw_AddWindowBox( PHB_GT pGT, int iWindow, BYTE * szBox, int iColor )
{
int iMaxRow, iMaxCol;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_AddWindowBox(%p,%d,%p,%d)", pGT, iWindow, szBox, iColor));
iMaxRow = HB_GTSELF_MAXROW( pGT );
iMaxCol = HB_GTSELF_MAXCOL( pGT );
if( iMaxRow > 1 && iMaxCol > 1 )
{
if( iColor == 0 )
iColor = HB_GTSELF_GETCOLOR( pGT );
HB_GTSELF_BOX( pGT, 0, 0, iMaxRow, iMaxCol, szBox, iColor );
if( iWindow > 0 && iWindow <= s_iOpenWindows &&
s_windows[ iWindow ] != NULL )
{
HB_GTSELF_SETPOS( pGT, 0, 0 );
hb_ctw_ChangeMargins( pGT, iWindow, 1, 1, 1, 1 );
}
else
HB_GTSELF_SETPOS( pGT, 1, 1 );
return 0;
}
return -1;
}
| ctwin.c | 819 |
STATIC VOID | hb_ctw_gt_Init( PHB_GT pGT, FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE hFilenoStderr )
static void hb_ctw_gt_Init( PHB_GT pGT, FHANDLE hFilenoStdin, FHANDLE hFilenoStdout, FHANDLE hFilenoStderr )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_Init(%p,%p,%p,%p)", pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr));
HB_GTSUPER_INIT( pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr );
s_fInit = TRUE;
}
| ctwin.c | 850 |
STATIC VOID | hb_ctw_gt_Exit( PHB_GT pGT )
static void hb_ctw_gt_Exit( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_Exit(%p)", pGT));
if( s_iMaxWindow > 0 )
{
hb_ctw_CloseAllWindows( pGT );
hb_xfree( s_windows );
hb_xfree( s_windowStack );
hb_xfree( s_pWindowMap );
hb_xfree( s_pShadowMap );
s_windows = NULL;
s_windowStack = NULL;
s_pWindowMap = s_pShadowMap = NULL;
s_iMaxWindow = s_iOpenWindows = s_iCurrWindow =
s_iMapWidth = s_iMapHeight = 0;
s_fBoardSet = s_fInit = FALSE;
}
HB_GTSUPER_EXIT( pGT );
}
| ctwin.c | 859 |
STATIC INT | hb_ctw_MouseRow( PHB_GT pGT )
static int hb_ctw_MouseRow( PHB_GT pGT )
{
int iRow;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_MouseRow(%p)", pGT));
iRow = HB_GTSUPER_MOUSEROW( pGT );
if( s_iCurrWindow > 0 )
iRow -= s_windows[ s_iCurrWindow ]->iFirstRow +
s_windows[ s_iCurrWindow ]->iTopMargin;
return iRow;
}
| ctwin.c | 882 |
STATIC INT | hb_ctw_MouseCol( PHB_GT pGT )
static int hb_ctw_MouseCol( PHB_GT pGT )
{
int iCol;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_MouseCol(%p)", pGT));
iCol = HB_GTSUPER_MOUSECOL( pGT );
if( s_iCurrWindow > 0 )
iCol -= s_windows[ s_iCurrWindow ]->iFirstCol +
s_windows[ s_iCurrWindow ]->iLeftMargin;
return iCol;
}
| ctwin.c | 897 |
STATIC VOID | hb_ctw_gt_GetPos( PHB_GT pGT, int * piRow, int * piCol )
static void hb_ctw_gt_GetPos( PHB_GT pGT, int * piRow, int * piCol )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetPos(%p,%p,%p)", pGT, piRow, piCol));
if( s_iCurrWindow > 0 )
{
*piRow = s_windows[ s_iCurrWindow ]->iRow;
*piCol = s_windows[ s_iCurrWindow ]->iCol;
}
else
HB_GTSUPER_GETPOS( pGT, piRow, piCol );
}
| ctwin.c | 912 |
STATIC VOID | hb_ctw_gt_SetPos( PHB_GT pGT, int iRow, int iCol )
static void hb_ctw_gt_SetPos( PHB_GT pGT, int iRow, int iCol )
{
int iHeight, iWidth;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetPos(%p,%d,%d)", pGT, iRow, iCol));
iHeight = HB_GTSELF_MAXROW( pGT ) + 1;
iWidth = HB_GTSELF_MAXCOL( pGT ) + 1;
if( iCol > iWidth )
iCol = iWidth;
else if( iCol < 0 )
{
iRow += iCol / iWidth - 1;
iCol = iWidth + iCol % iWidth;
}
if( iRow > iHeight )
iRow = iHeight;
if( s_iCurrWindow > 0 )
{
if( iRow < - s_windows[ s_iCurrWindow ]->iTopMargin )
iRow = - s_windows[ s_iCurrWindow ]->iTopMargin;
s_windows[ s_iCurrWindow ]->iRow = iRow;
s_windows[ s_iCurrWindow ]->iCol = iCol;
}
else
{
if( iRow < 0 )
iRow = 0;
HB_GTSUPER_SETPOS( pGT, iRow, iCol );
}
}
| ctwin.c | 925 |
STATIC INT | hb_ctw_gt_MaxCol( PHB_GT pGT )
static int hb_ctw_gt_MaxCol( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_MaxCol(%p)", pGT));
if( s_iCurrWindow > 0 )
return s_windows[ s_iCurrWindow ]->iWidth -
s_windows[ s_iCurrWindow ]->iLeftMargin -
s_windows[ s_iCurrWindow ]->iRightMargin - 1;
else
return HB_GTSUPER_MAXCOL( pGT );
}
| ctwin.c | 964 |
STATIC INT | hb_ctw_gt_MaxRow( PHB_GT pGT )
static int hb_ctw_gt_MaxRow( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_MaxRow(%p)", pGT));
if( s_iCurrWindow > 0 )
return s_windows[ s_iCurrWindow ]->iHeight -
s_windows[ s_iCurrWindow ]->iTopMargin -
s_windows[ s_iCurrWindow ]->iBottomMargin - 1;
else
return HB_GTSUPER_MAXROW( pGT );
}
| ctwin.c | 976 |
STATIC VOID | hb_ctw_gt_WriteCon( PHB_GT pGT, BYTE * pText, ULONG ulLength )
static void hb_ctw_gt_WriteCon( PHB_GT pGT, BYTE * pText, ULONG ulLength )
{
int iLen = 0;
BOOL bDisp = FALSE;
BOOL bBell = FALSE;
int iRow, iCol, iMaxRow, iMaxCol;
BYTE szString[ WRITECON_BUFFER_SIZE ];
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_WriteCon(%p,%p,%lu)", pGT, pText, ulLength));
iMaxRow = HB_GTSELF_MAXROW( pGT );
iMaxCol = HB_GTSELF_MAXCOL( pGT );
HB_GTSELF_GETPOS( pGT, &iRow, &iCol );
if( iRow > iMaxRow || iCol > iMaxCol )
{
if( iRow > iMaxRow )
iRow = iMaxRow;
if( iCol > iMaxCol )
iCol = iMaxCol;
HB_GTSELF_SETPOS( pGT, iRow, iCol );
}
while( ulLength-- )
{
BYTE ch = *pText++;
switch( ch )
{
case HB_CHAR_BEL:
bDisp = bBell = TRUE;
break;
case HB_CHAR_BS:
if( iCol > 0 )
{
--iCol;
bDisp = TRUE;
}
else if( iRow > 0 )
{
iCol = iMaxCol;
--iRow;
bDisp = TRUE;
}
if( bDisp )
{
if( iLen )
szString[ iLen - 1 ] = ' ';
else
{
HB_GTSELF_SETPOS( pGT, iRow, iCol );
szString[ iLen++ ] = ' ';
}
}
break;
case HB_CHAR_LF:
iCol = 0;
++iRow;
bDisp = TRUE;
break;
case HB_CHAR_CR:
iCol = 0;
if( *pText == HB_CHAR_LF )
{
++iRow;
++pText;
--ulLength;
}
bDisp = TRUE;
break;
default:
szString[ iLen++ ] = ch;
if( ++iCol > iMaxCol )
{
iCol = 0;
++iRow;
bDisp = TRUE;
}
else if( iLen >= WRITECON_BUFFER_SIZE )
bDisp = TRUE;
}
if( bDisp || ulLength == 0 )
{
if( iLen )
HB_GTSELF_WRITE( pGT, szString, iLen );
iLen = 0;
if( iRow > iMaxRow )
{
HB_GTSELF_SCROLL( pGT, 0, 0, iMaxRow, iMaxCol,
HB_GTSELF_GETCOLOR( pGT ),
HB_GTSELF_GETCLEARCHAR( pGT ),
iRow - iMaxRow, 0 );
iRow = iMaxRow;
iCol = 0;
}
HB_GTSELF_SETPOS( pGT, iRow, iCol );
bDisp = FALSE;
/* To emulate scrolling */
HB_GTSELF_FLUSH( pGT );
if( bBell )
{
HB_GTSELF_BELL( pGT );
bBell = FALSE;
}
}
}
}
| ctwin.c | 994 |
STATIC INT | hb_ctw_gt_GetCursorStyle( PHB_GT pGT )
static int hb_ctw_gt_GetCursorStyle( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetCursorStyle(%p)", pGT));
if( s_iCurrWindow > 0 )
return s_windows[ s_iCurrWindow ]->iCursorStyle;
else
return HB_GTSUPER_GETCURSORSTYLE( pGT );
}
| ctwin.c | 1112 |
STATIC VOID | hb_ctw_gt_SetCursorStyle( PHB_GT pGT, int iStyle )
static void hb_ctw_gt_SetCursorStyle( PHB_GT pGT, int iStyle )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_SetCursorStyle(%p,%d)", pGT, iStyle));
if( s_iCurrWindow > 0 )
{
switch( iStyle )
{
case SC_NONE:
case SC_NORMAL:
case SC_INSERT:
case SC_SPECIAL1:
case SC_SPECIAL2:
s_windows[ s_iCurrWindow ]->iCursorStyle = iStyle;
break;
default:
s_windows[ s_iCurrWindow ]->iCursorStyle = SC_NORMAL;
break;
}
}
else
HB_GTSUPER_SETCURSORSTYLE( pGT, iStyle );
}
| ctwin.c | 1122 |
STATIC VOID | hb_ctw_gt_GetColorStr( PHB_GT pGT, char * pszColorString )
static void hb_ctw_gt_GetColorStr( PHB_GT pGT, char * pszColorString )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetColorStr(%p,%p)", pGT, pszColorString));
if( s_iCurrWindow > 0 )
{
PHB_CT_WND pWnd = s_windows[ s_iCurrWindow ];
HB_GTSUPER_COLORSTOSTRING( pGT, pWnd->piColors, pWnd->iColorCount, pszColorString, CLR_STRLEN );
}
else
HB_GTSUPER_GETCOLORSTR( pGT, pszColorString );
}
| ctwin.c | 1146 |
STATIC VOID | hb_ctw_gt_SetColorStr( PHB_GT pGT, const char * szColorString )
static void hb_ctw_gt_SetColorStr( PHB_GT pGT, const char * szColorString )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_SetColorStr(%p,%s)", pGT, szColorString));
if( s_iCurrWindow > 0 )
{
PHB_CT_WND pWnd = s_windows[ s_iCurrWindow ];
HB_GTSUPER_STRINGTOCOLORS( pGT, szColorString, &pWnd->piColors, &pWnd->iColorCount );
pWnd->iColorIndex = HB_CLR_STANDARD;
}
else
HB_GTSUPER_SETCOLORSTR( pGT, szColorString );
}
| ctwin.c | 1159 |
STATIC VOID | hb_ctw_gt_ColorSelect( PHB_GT pGT, int iColorIndex )
static void hb_ctw_gt_ColorSelect( PHB_GT pGT, int iColorIndex )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_ColorSelect(%p,%d)", pGT, iColorIndex));
if( s_iCurrWindow > 0 )
{
PHB_CT_WND pWnd = s_windows[ s_iCurrWindow ];
if( iColorIndex >= 0 && iColorIndex < pWnd->iColorCount )
pWnd->iColorIndex = iColorIndex;
}
else
HB_GTSUPER_COLORSELECT( pGT, iColorIndex );
}
| ctwin.c | 1173 |
STATIC INT | hb_ctw_gt_GetColor( PHB_GT pGT )
static int hb_ctw_gt_GetColor( PHB_GT pGT )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetColor(%p)", pGT));
if( s_iCurrWindow > 0 )
{
PHB_CT_WND pWnd = s_windows[ s_iCurrWindow ];
return pWnd->piColors[ pWnd->iColorIndex ];
}
else
return HB_GTSUPER_GETCOLOR( pGT );
}
| ctwin.c | 1187 |
STATIC VOID | hb_ctw_gt_GetColorData( PHB_GT pGT, int ** pColorsPtr, int * piColorCount, int * piColorIndex )
static void hb_ctw_gt_GetColorData( PHB_GT pGT, int ** pColorsPtr, int * piColorCount, int * piColorIndex )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetColor(%p,%p,%p,%p)", pGT, pColorsPtr, piColorCount, piColorIndex));
if( s_iCurrWindow > 0 )
{
PHB_CT_WND pWnd = s_windows[ s_iCurrWindow ];
*pColorsPtr = ( int * ) hb_xgrab( pWnd->iColorCount * sizeof( int ) );
memcpy( *pColorsPtr, pWnd->piColors, pWnd->iColorCount * sizeof( int ) );
*piColorCount = pWnd->iColorCount;
*piColorIndex = pWnd->iColorIndex;
}
else
HB_GTSUPER_GETCOLORDATA( pGT, pColorsPtr, piColorCount, piColorIndex );
}
| ctwin.c | 1200 |
STATIC VOID | hb_ctw_gt_GetScrCursor( PHB_GT pGT, int * piRow, int * piCol, int * piStyle )
static void hb_ctw_gt_GetScrCursor( PHB_GT pGT, int * piRow, int * piCol, int * piStyle )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetScrCursor(%p,%p,%p,%p)", pGT, piRow, piCol, piStyle));
HB_GTSUPER_GETSCRCURSOR( pGT, piRow, piCol, piStyle );
if( s_iCurrWindow > 0 )
{
*piRow += s_windows[ s_iCurrWindow ]->iFirstRow +
s_windows[ s_iCurrWindow ]->iTopMargin;
*piCol += s_windows[ s_iCurrWindow ]->iFirstCol +
s_windows[ s_iCurrWindow ]->iLeftMargin;
if( *piStyle != SC_NONE &&
( *piRow < s_iBoardTop || *piRow > s_iBoardBottom ||
*piCol < s_iBoardLeft || *piCol > s_iBoardRight ) )
*piStyle = SC_NONE;
}
}
| ctwin.c | 1217 |
STATIC BOOL | hb_ctw_gt_GetScrChar( PHB_GT pGT, int iRow, int iCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
static BOOL hb_ctw_gt_GetScrChar( PHB_GT pGT, int iRow, int iCol,
BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
{
int iWindow = s_iCurrWindow, iShadow = 0;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetScrChar(%p,%d,%d,%p,%p,%p)", pGT, iRow, iCol, pbColor, pbAttr, pusChar));
if( s_iOpenWindows > 0 )
{
if( iRow < s_iBoardTop || iRow > s_iBoardBottom ||
iCol < s_iBoardLeft || iCol > s_iBoardRight )
iWindow = 0;
else
{
long lIndex = ( long ) iRow * s_iMapWidth + iCol;
iWindow = s_pWindowMap[ lIndex ];
iShadow = s_pShadowMap[ lIndex ];
}
}
if( iWindow > 0 )
{
iRow -= s_windows[ iWindow ]->iFirstRow;
iCol -= s_windows[ iWindow ]->iFirstCol;
if( iCol >= 0 && iRow >= 0 && iRow < s_windows[ iWindow ]->iHeight &&
iCol < s_windows[ iWindow ]->iWidth )
{
long lIndex = ( long ) iRow * s_windows[ iWindow ]->iWidth + iCol;
*pusChar = s_windows[ iWindow ]->screenBuffer[ lIndex ].c.usChar;
*pbColor = s_windows[ iWindow ]->screenBuffer[ lIndex ].c.bColor;
*pbAttr = s_windows[ iWindow ]->screenBuffer[ lIndex ].c.bAttr;
}
else
return FALSE;
}
else if( ! HB_GTSUPER_GETSCRCHAR( pGT, iRow, iCol, pbColor, pbAttr, pusChar ) )
return FALSE;
if( iShadow > 0 )
{
if( s_windows[ iShadow ]->iShadowAttr >= 0 )
*pbColor = ( BYTE ) s_windows[ iShadow ]->iShadowAttr;
*pbAttr |= HB_GT_ATTR_SHADOW;
}
return TRUE;
}
| ctwin.c | 1235 |
STATIC BOOL | hb_ctw_gt_GetChar( PHB_GT pGT, int iRow, int iCol, BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
static BOOL hb_ctw_gt_GetChar( PHB_GT pGT, int iRow, int iCol,
BYTE * pbColor, BYTE * pbAttr, USHORT * pusChar )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_GetChar(%p,%d,%d,%p,%p,%p)", pGT, iRow, iCol, pbColor, pbAttr, pusChar));
if( s_iCurrWindow == 0 )
/* TODO: it may badly interacts with character translations */
return HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, pbColor, pbAttr, pusChar );
iRow += s_windows[ s_iCurrWindow ]->iTopMargin;
iCol += s_windows[ s_iCurrWindow ]->iLeftMargin;
if( iCol >= 0 && iRow >= 0 &&
iRow < s_windows[ s_iCurrWindow ]->iHeight &&
iCol < s_windows[ s_iCurrWindow ]->iWidth )
{
long lIndex = ( long ) iRow * s_windows[ s_iCurrWindow ]->iWidth + iCol;
*pusChar = s_windows[ s_iCurrWindow ]->screenBuffer[ lIndex ].c.usChar;
*pbColor = s_windows[ s_iCurrWindow ]->screenBuffer[ lIndex ].c.bColor;
*pbAttr = s_windows[ s_iCurrWindow ]->screenBuffer[ lIndex ].c.bAttr;
return TRUE;
}
return FALSE;
}
| ctwin.c | 1283 |
STATIC BOOL | hb_ctw_gt_PutChar( PHB_GT pGT, int iRow, int iCol, BYTE bColor, BYTE bAttr, USHORT usChar )
static BOOL hb_ctw_gt_PutChar( PHB_GT pGT, int iRow, int iCol,
BYTE bColor, BYTE bAttr, USHORT usChar )
{
int iWindow = s_iCurrWindow;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_PutChar(%p,%d,%d,%d,%d,%hu)", pGT, iRow, iCol, (int)bColor, (int)bAttr, (int)usChar));
if( s_iOpenWindows > 0 && iWindow == 0 )
{
if( iRow >= s_iBoardTop && iRow <= s_iBoardBottom &&
iCol >= s_iBoardLeft && iCol <= s_iBoardRight )
{
long lIndex = ( long ) iRow * s_iMapWidth + iCol;
iWindow = s_pWindowMap[ lIndex ];
#if 0
/* When window with shadow is closed CT3 restores attributes
* which existed before shadow was displayed. In some application
* which switches to window 0 for pass-throw output it causes that
* wrong attributes appears after this operation. In Harbour it's
* fixed so such problem do not exist. Anyhow some code may switch
* to window 0, make savescreen()/restscreen() and in such case
* all shadow attributes are copied to window 0 buffer. The code
* below is workaround for it. [druzus]
*/
if( s_pShadowMap[ lIndex ] != 0 )
{
int iShadow = s_pShadowMap[ lIndex ];
if( s_windows[ iShadow ]->iShadowAttr >= 0 &&
( BYTE ) s_windows[ iShadow ]->iShadowAttr == bColor )
{
BYTE bClr, bAtr;
USHORT usCh;
if( HB_GTSELF_GETSCRCHAR( pGT, iRow, iCol, &bClr, &bAtr, &usCh ) )
{
if( usCh == usChar && bClr == bColor )
return TRUE;
}
}
}
#endif
s_pShadowMap[ lIndex ] = 0;
}
}
if( iWindow > 0 )
{
int iWndRow, iWndCol, iWndHeight, iWndWidth;
if( s_iCurrWindow == 0 )
{
iWndRow = iRow - s_windows[ iWindow ]->iFirstRow;
iWndCol = iCol - s_windows[ iWindow ]->iFirstCol;
iWndHeight = s_windows[ iWindow ]->iWidth;
iWndWidth = s_windows[ iWindow ]->iWidth;
}
else
{
iWndRow = iRow + s_windows[ iWindow ]->iTopMargin;
iWndCol = iCol + s_windows[ iWindow ]->iLeftMargin;
iRow = iWndRow + s_windows[ iWindow ]->iFirstRow;
iCol = iWndCol + s_windows[ iWindow ]->iFirstCol;
iWndHeight = s_windows[ iWindow ]->iHeight -
s_windows[ iWindow ]->iBottomMargin;
iWndWidth = s_windows[ iWindow ]->iWidth -
s_windows[ iWindow ]->iRightMargin;
}
if( iWndCol >= 0 && iWndRow >= 0 &&
iWndRow < iWndHeight &&
iWndCol < iWndWidth )
{
long lIndex = ( long ) iWndRow * s_windows[ iWindow ]->iWidth + iWndCol;
s_windows[ iWindow ]->screenBuffer[ lIndex ].c.usChar = usChar;
s_windows[ iWindow ]->screenBuffer[ lIndex ].c.bColor = bColor;
s_windows[ iWindow ]->screenBuffer[ lIndex ].c.bAttr = bAttr;
if( ! s_windows[ iWindow ]->fHidden )
{
if( s_iCurrWindow == 0 )
HB_GTSUPER_TOUCHCELL( pGT, iRow, iCol );
else if( iRow >= s_iBoardTop && iRow <= s_iBoardBottom &&
iCol >= s_iBoardLeft && iCol <= s_iBoardRight )
HB_GTSUPER_TOUCHCELL( pGT, iRow, iCol );
}
return TRUE;
}
return FALSE;
}
return HB_GTSUPER_PUTCHAR( pGT, iRow, iCol, bColor, bAttr, usChar );
}
| ctwin.c | 1309 |
STATIC BOOL | hb_ctw_gt_Resize( PHB_GT pGT, int iRows, int iCols )
static BOOL hb_ctw_gt_Resize( PHB_GT pGT, int iRows, int iCols )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_Resize(%p,%d,%d)", pGT, iRows, iCols));
if( HB_GTSUPER_RESIZE( pGT, iRows, iCols ) )
{
if( s_iMaxWindow > 0 )
{
ULONG ulSize;
s_iMapHeight = iRows;
s_iMapWidth = iCols;
s_iShadowWidth = hb_ctw_CalcShadowWidth( s_iMapHeight, s_iMapWidth );
ulSize = ( ULONG ) s_iMapHeight * s_iMapWidth * sizeof( int );
s_pWindowMap = ( int * ) hb_xrealloc( s_pWindowMap, ulSize );
s_pShadowMap = ( int * ) hb_xrealloc( s_pShadowMap, ulSize );
}
if( s_fBoardSet )
hb_ctw_SetWindowBoard( pGT, 0, 0, iRows - 1, iCols - 1 );
return TRUE;
}
return FALSE;
}
| ctwin.c | 1400 |
STATIC BOOL | hb_ctw_gt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
static BOOL hb_ctw_gt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
{
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_Info(%p,%d,%p)", pGT, iType, pInfo));
switch ( iType )
{
case GTI_ISCTWIN:
pInfo->pResult = hb_itemPutL( pInfo->pResult, TRUE );
break;
case GTI_NEWWIN:
{
BOOL fResult;
hb_ctw_SelectWindow( pGT, 0 );
fResult = HB_GTSUPER_INFO( pGT, iType, pInfo );
if( fResult && hb_arrayLen( pInfo->pResult ) >= 8 )
hb_itemPutNI( hb_arrayGetItemPtr( pInfo->pResult, 8 ),
s_iCurrWindow );
return fResult;
}
case GTI_GETWIN:
{
BOOL fResult;
int iWindow = s_iCurrWindow;
hb_ctw_SelectWindow( pGT, 0 );
fResult = HB_GTSUPER_INFO( pGT, iType, pInfo );
if( fResult && hb_arrayLen( pInfo->pResult ) >= 8 )
hb_itemPutNI( hb_arrayGetItemPtr( pInfo->pResult, 8 ), iWindow );
return fResult;
}
case GTI_SETWIN:
{
BOOL fResult;
hb_ctw_SelectWindow( pGT, 0 );
fResult = HB_GTSUPER_INFO( pGT, iType, pInfo );
if( hb_arrayLen( pInfo->pNewVal ) == 8 )
hb_ctw_SelectWindow( pGT, hb_arrayGetNI( pInfo->pNewVal, 8 ) );
return fResult;
}
default:
return HB_GTSUPER_INFO( pGT, iType, pInfo );
}
return TRUE;
}
| ctwin.c | 1424 |
STATIC INT | hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, int iClrNorm, int iClrHigh, double dDelay )
static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions,
int iClrNorm, int iClrHigh, double dDelay )
{
int iOptions, iRet = 0;
HB_TRACE( HB_TR_DEBUG, ("hb_ctw_gt_Alert(%p,%p,%p,%d,%d,%f)", pGT, pMessage, pOptions, iClrNorm, iClrHigh, dDelay ) );
iOptions = ( int ) hb_arrayLen( pOptions );
if( HB_IS_STRING( pMessage ) && iOptions > 0 )
{
int iRows, iCols;
BOOL fScreen;
HB_GTSELF_GETSIZE( pGT, &iRows, &iCols );
if( iCols <= 4 || iRows <= 4 )
fScreen = FALSE;
else
{
HB_GT_INFO gtInfo;
gtInfo.pNewVal = gtInfo.pResult = NULL;
HB_GTSELF_INFO( pGT, GTI_FULLSCREEN, >Info );
fScreen = gtInfo.pResult && hb_itemGetL( gtInfo.pResult );
HB_GTSELF_INFO( pGT, GTI_KBDSUPPORT, >Info );
if( gtInfo.pResult )
{
if( !hb_itemGetL( gtInfo.pResult ) )
fScreen = FALSE;
hb_itemRelease( gtInfo.pResult );
}
}
if( fScreen )
{
ULONG ulWidth = 0, ulCurrWidth = 0, ul = 0, ul2, ulMaxWidth, ulLast;
int iKey, iDspCount, iLines = 0, iTop, iLeft, iBottom, iRight,
iMnuCol, iPos, iClr, iWnd, i;
char * szMessage = hb_itemGetCPtr( pMessage );
ULONG ulLen = hb_itemGetCLen( pMessage );
ulMaxWidth = iCols - 4;
while( ul < ulLen )
{
if( szMessage[ ul ] == '\n' )
{
++iLines;
if( ulCurrWidth > ulWidth )
ulWidth = ulCurrWidth;
ulCurrWidth = 0;
}
else
++ulCurrWidth;
++ul;
}
if( ulCurrWidth )
++iLines;
if( ulCurrWidth > ulWidth )
ulWidth = ulCurrWidth;
ulCurrWidth = 0;
for( i = 1; i <= iOptions; ++i )
{
ulCurrWidth += hb_arrayGetCLen( pOptions, i ) + ( i > 1 ? 3 : 0 );
}
if( ulCurrWidth > ulWidth )
ulWidth = ulCurrWidth;
if( ulWidth > ulMaxWidth )
ulWidth = ulMaxWidth;
if( iRows < iLines + 4 )
iLines = iRows - 4;
iTop = ( iRows - iLines - 4 ) >> 1;
iLeft = ( iCols - ulWidth - 4 ) >> 1;
iBottom = iTop + iLines + 3;
iRight = iLeft + ulWidth + 3;
if( iClrNorm == 0 )
iClrNorm = 79;
if( iClrHigh == 0 )
iClrHigh = 31;
iDspCount = HB_GTSELF_DISPCOUNT( pGT );
if( iDspCount == 0 )
HB_GTSELF_DISPBEGIN( pGT );
iWnd = hb_ctw_CreateWindow( pGT, iTop, iLeft, iBottom, iRight, TRUE, iClrNorm );
hb_ctw_AddWindowBox( pGT, iWnd, ( BYTE * ) _B_SINGLE, iClrNorm );
HB_GTSELF_SETCURSORSTYLE( pGT, SC_NONE );
ulLast = 0;
i = 0;
for( ul = 0; ul < ulLen; ++ul )
{
if( szMessage[ ul ] == '\n' )
{
if( ul > ulLast )
{
ul2 = ul - ulLast;
if( ul2 > ulWidth )
ul2 = ulWidth;
HB_GTSELF_PUTTEXT( pGT, i, ( ( ulWidth - ul2 + 1 ) >> 1 ) + 1, iClrNorm,
( BYTE * ) szMessage + ulLast, ul2 );
}
ulLast = ul + 1;
if( ++i >= iLines )
break;
}
}
if( ul > ulLast && i < iLines )
{
ul2 = ul - ulLast;
if( ul2 > ulWidth )
ul2 = ulWidth;
HB_GTSELF_PUTTEXT( pGT, i, ( ( ulWidth - ul2 + 1 ) >> 1 ) + 1, iClrNorm,
( BYTE * ) szMessage + ulLast, ul2 );
}
iPos = 1;
while( iRet == 0 )
{
HB_GTSELF_DISPBEGIN( pGT );
iMnuCol = ( ( ulWidth - ulCurrWidth ) >> 1 ) + 1;
for( i = 1; i <= iOptions; ++i )
{
iClr = i == iPos ? iClrHigh : iClrNorm;
ulLen = hb_arrayGetCLen( pOptions, i );
HB_GTSELF_PUTTEXT( pGT, iLines + 1, iMnuCol, iClr,
( BYTE * ) hb_arrayGetCPtr( pOptions, i ), ulLen );
iMnuCol += ulLen + 3;
}
while( HB_GTSELF_DISPCOUNT( pGT ) )
HB_GTSELF_DISPEND( pGT );
HB_GTSELF_REFRESH( pGT );
iKey = HB_GTSELF_INKEYGET( pGT, TRUE, dDelay, INKEY_ALL );
/* TODO: add support for SET KEY blocks */
if( iKey == K_ESC )
break;
else if( iKey == K_ENTER || iKey == K_SPACE || iKey == 0 )
{
iRet = iPos;
}
else if( iKey == K_LEFT || iKey == K_SH_TAB )
{
if( --iPos == 0 )
iPos = iOptions;
dDelay = 0.0;
}
else if( iKey == K_RIGHT || iKey == K_TAB )
{
if( ++iPos > iOptions )
iPos = 1;
dDelay = 0.0;
}
#ifdef HB_COMPAT_C53
else if( iKey == K_LBUTTONDOWN )
{
int iMRow = HB_GTSELF_MOUSEROW( pGT ),
iMCol = HB_GTSELF_MOUSECOL( pGT );
if( iMRow == iLines + 1 )
{
iMnuCol = ( ( ulWidth - ulCurrWidth ) >> 1 ) + 1;
for( i = 1; i <= iOptions; ++i )
{
ulLen = hb_arrayGetCLen( pOptions, i );
if( iMCol >= iMnuCol && iMCol < iMnuCol + ( int ) ulLen )
{
iRet = i;
break;
}
iMnuCol += ulLen + 3;
}
}
}
#endif
else if( iKey >= 32 && iKey <= 255 )
{
int iUp = hb_charUpper( iKey );
for( i = 1; i <= iOptions; ++i )
{
char *szValue = hb_arrayGetCPtr( pOptions, i );
if( szValue && iUp == hb_charUpper( *szValue ) )
{
iRet = i;
break;
}
}
}
}
hb_ctw_CloseWindow( pGT, iWnd );
HB_GTSELF_REFRESH( pGT );
while( HB_GTSELF_DISPCOUNT( pGT ) < iDspCount )
HB_GTSELF_DISPBEGIN( pGT );
return iRet;
}
}
return HB_GTSUPER_ALERT( pGT, pMessage, pOptions, iClrNorm, iClrHigh, dDelay );
}
| ctwin.c | 1474 |
STATIC INT | hb_ctw_gt_ReadKey( PHB_GT pGT, int iEventMask )
static int hb_ctw_gt_ReadKey( PHB_GT pGT, int iEventMask )
{
int iKey;
HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_ReadKey(%p,%d)", pGT, iEventMask));
iKey = HB_GTSUPER_READKEY( pGT, iEventMask );
if( iKey != 0 )
s_iLastKey = iKey;
return iKey;
}
| ctwin.c | 1673 |
BOOL | hb_ctwInit( void )
BOOL hb_ctwInit( void )
{
PHB_GT pGT = hb_gt_Base();
BOOL fResult = FALSE;
if( pGT )
fResult = hb_ctw_Init( pGT );
return fResult;
}
| ctwin.c | 1689 |
INT | hb_ctwSetShadowAttr( int iAttr )
int hb_ctwSetShadowAttr( int iAttr )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_SetShadowAttr( pGT, iAttr );
return iResult;
}
| ctwin.c | 1698 |
INT | hb_ctwSetMoveMode( int iMode )
int hb_ctwSetMoveMode( int iMode )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_SetMoveMode( pGT, iMode );
return iResult;
}
| ctwin.c | 1707 |
INT | hb_ctwSetMoveStep( int iVertical, int iHorizontal )
int hb_ctwSetMoveStep( int iVertical, int iHorizontal )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_SetMoveStep( pGT, iVertical, iHorizontal );
return iResult;
}
| ctwin.c | 1716 |
INT | hb_ctwSetWindowBoard( int iTop, int iLeft, int iBottom, int iRight )
int hb_ctwSetWindowBoard( int iTop, int iLeft, int iBottom, int iRight )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
{
iResult = hb_ctw_SetWindowBoard( pGT, iTop, iLeft, iBottom, iRight );
HB_GTSELF_FLUSH( pGT );
}
return iResult;
}
| ctwin.c | 1725 |
INT | hb_ctwSetBorderMode( int iTop, int iLeft, int iBottom, int iRight )
int hb_ctwSetBorderMode( int iTop, int iLeft, int iBottom, int iRight )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_SetBorderMode( pGT, iTop, iLeft, iBottom, iRight );
return iResult;
}
| ctwin.c | 1737 |
INT | hb_ctwCreateWindow( int iTop, int iLeft, int iBottom, int iRight, BOOL fClear, int iColor )
int hb_ctwCreateWindow( int iTop, int iLeft, int iBottom, int iRight, BOOL fClear, int iColor )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
{
iResult = hb_ctw_CreateWindow( pGT, iTop, iLeft, iBottom, iRight, fClear, iColor );
HB_GTSELF_FLUSH( pGT );
}
return iResult;
}
| ctwin.c | 1746 |
INT | hb_ctwCloseAllWindows( void )
int hb_ctwCloseAllWindows( void )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
{
iResult = hb_ctw_CloseAllWindows( pGT );
HB_GTSELF_FLUSH( pGT );
}
return iResult;
}
| ctwin.c | 1758 |
INT | hb_ctwCloseWindow( int iWindow )
int hb_ctwCloseWindow( int iWindow )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
{
iResult = hb_ctw_CloseWindow( pGT, iWindow );
HB_GTSELF_FLUSH( pGT );
}
return iResult;
}
| ctwin.c | 1770 |
INT | hb_ctwCurrentWindow( void )
int hb_ctwCurrentWindow( void )
{
PHB_GT pGT = hb_gt_Base();
int iResult = 0;
if( pGT )
iResult = hb_ctw_CurrentWindow( pGT );
return iResult;
}
| ctwin.c | 1782 |
INT | hb_ctwSelectWindow( int iWindow )
int hb_ctwSelectWindow( int iWindow )
{
PHB_GT pGT = hb_gt_Base();
int iResult = 0;
if( pGT )
{
iResult = hb_ctw_SelectWindow( pGT, iWindow );
HB_GTSELF_FLUSH( pGT );
}
return iResult;
}
| ctwin.c | 1791 |
INT | hb_ctwMaxWindow( void )
int hb_ctwMaxWindow( void )
{
PHB_GT pGT = hb_gt_Base();
int iResult = 0;
if( pGT )
iResult = hb_ctw_MaxWindow( pGT );
return iResult;
}
| ctwin.c | 1803 |
INT | hb_ctwChangeMargins( int iWindow, int iTop, int iLeft, int iBottom, int iRight )
int hb_ctwChangeMargins( int iWindow, int iTop, int iLeft, int iBottom, int iRight )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_ChangeMargins( pGT, iWindow, iTop, iLeft, iBottom, iRight );
return iResult;
}
| ctwin.c | 1812 |
INT | hb_ctwGetWindowCords( int iWindow, BOOL fCenter, int * piTop, int * piLeft, int * piBottom, int * piRight )
int hb_ctwGetWindowCords( int iWindow, BOOL fCenter, int * piTop, int * piLeft, int * piBottom, int * piRight )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_GetWindowCords( pGT, iWindow, fCenter, piTop, piLeft, piBottom, piRight );
return iResult;
}
| ctwin.c | 1821 |
INT | hb_ctwGetFormatCords( int iWindow, BOOL fRelative, int * piTop, int * piLeft, int * piBottom, int * piRight )
int hb_ctwGetFormatCords( int iWindow, BOOL fRelative, int * piTop, int * piLeft, int * piBottom, int * piRight )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_GetFormatCords( pGT, iWindow, fRelative, piTop, piLeft, piBottom, piRight );
return iResult;
}
| ctwin.c | 1830 |
INT | hb_ctwMoveWindow( int iWindow, int iRow, int iCol )
int hb_ctwMoveWindow( int iWindow, int iRow, int iCol )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_MoveWindow( pGT, iWindow, iRow, iCol );
return iResult;
}
| ctwin.c | 1839 |
INT | hb_ctwCenterWindow( int iWindow, BOOL fCenter )
int hb_ctwCenterWindow( int iWindow, BOOL fCenter )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
iResult = hb_ctw_CenterWindow( pGT, iWindow, fCenter );
return iResult;
}
| ctwin.c | 1848 |
INT | hb_ctwAddWindowBox( int iWindow, BYTE * szBox, int iColor )
int hb_ctwAddWindowBox( int iWindow, BYTE * szBox, int iColor )
{
PHB_GT pGT = hb_gt_Base();
int iResult = -1;
if( pGT )
{
iResult = hb_ctw_AddWindowBox( pGT, iWindow, szBox, iColor );
HB_GTSELF_FLUSH( pGT );
}
return iResult;
}
| ctwin.c | 1857 |
INT | hb_ctwLastKey( void )
int hb_ctwLastKey( void )
{
/* keyread() in CT3 uses 64512 bytes length buffer
* when it reach this limit and new key is added the
* buffer size is decreased by 1024 to 63488 bytes
* before adding key. TODO: check id buffer is shifted
*/
if( !s_fInit )
{
PHB_GT pGT = hb_gt_Base();
if( pGT )
hb_ctw_Init( pGT );
}
return s_iLastKey;
}
| ctwin.c | 1869 |
STATIC BOOL | hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
{
HB_TRACE(HB_TR_DEBUG, ("hb_gt_FuncInit(%p)", pFuncTable));
pFuncTable->Init = hb_ctw_gt_Init;
pFuncTable->Exit = hb_ctw_gt_Exit;
pFuncTable->MouseRow = hb_ctw_MouseRow;
pFuncTable->MouseCol = hb_ctw_MouseCol;
pFuncTable->MaxCol = hb_ctw_gt_MaxCol;
pFuncTable->MaxRow = hb_ctw_gt_MaxRow;
pFuncTable->GetPos = hb_ctw_gt_GetPos;
pFuncTable->SetPos = hb_ctw_gt_SetPos;
pFuncTable->WriteCon = hb_ctw_gt_WriteCon;
pFuncTable->GetCursorStyle = hb_ctw_gt_GetCursorStyle;
pFuncTable->SetCursorStyle = hb_ctw_gt_SetCursorStyle;
pFuncTable->GetColorStr = hb_ctw_gt_GetColorStr;
pFuncTable->SetColorStr = hb_ctw_gt_SetColorStr;
pFuncTable->ColorSelect = hb_ctw_gt_ColorSelect;
pFuncTable->GetColor = hb_ctw_gt_GetColor;
pFuncTable->GetColorData = hb_ctw_gt_GetColorData;
pFuncTable->GetScrCursor = hb_ctw_gt_GetScrCursor;
pFuncTable->GetScrChar = hb_ctw_gt_GetScrChar;
pFuncTable->GetChar = hb_ctw_gt_GetChar;
pFuncTable->PutChar = hb_ctw_gt_PutChar;
pFuncTable->Resize = hb_ctw_gt_Resize;
pFuncTable->Info = hb_ctw_gt_Info;
pFuncTable->Alert = hb_ctw_gt_Alert;
pFuncTable->ReadKey = hb_ctw_gt_ReadKey;
return TRUE;
}
/* ********************************************************************** */
static const HB_GT_INIT gtInit = { HB_GT_DRVNAME( HB_GT_NAME ),
hb_gt_FuncInit,
HB_GTSUPER,
HB_GTID_PTR };
HB_GT_ANNOUNCE( HB_GT_NAME )
HB_CALL_ON_STARTUP_BEGIN( _hb_startup_gt_Init_ )
hb_gtRegister( >Init );
HB_CALL_ON_STARTUP_END( _hb_startup_gt_Init_ )
#if defined( HB_PRAGMA_STARTUP )
#pragma startup _hb_startup_gt_Init_
#elif defined(HB_MSC_STARTUP)
#pragma data_seg( HB_MSC_START_SEGMENT )
static HB_$INITSYM hb_vm_auto__hb_startup_gt_Init_ = _hb_startup_gt_Init_;
#pragma data_seg()
#endif
| ctwin.c | 1885 |
cursor.c |
Type | Function | Source | Line |
HB_FUNC | SAVECURSOR(void)
HB_FUNC( SAVECURSOR )
{
SHORT sRow, sCol;
USHORT usCursor;
hb_gtGetPos( &sRow, &sCol );
hb_gtGetCursor( &usCursor );
#ifdef HB_C52_STRICT
usCursor = ( usCursor != 0 );
#endif
hb_retnl( ( long ) sCol | ( sRow << 8 ) | ( usCursor << 16 ) );
}
| cursor.c | 58 |
HB_FUNC | RESTCURSOR(void)
HB_FUNC( RESTCURSOR )
{
long lCursor = hb_parnl( 1 );
hb_gtSetPos( ( SHORT ) ( ( lCursor >> 8 ) & 0xff ), ( SHORT ) ( lCursor & 0xff ) );
#ifdef HB_C52_STRICT
hb_gtSetCursor( ( USHORT ) ( ( lCursor >> 16 ) & 0x01 ) );
#else
hb_gtSetCursor( ( USHORT ) ( ( lCursor >> 16 ) & 0xff ) );
#endif
hb_retc( NULL );
}
| cursor.c | 73 |
datetime.c |
Type | Function | Source | Line |
HB_FUNC | BOM(void)
HB_FUNC( BOM )
{
LONG lDate;
int iYear, iMonth, iDay;
if( ISNIL( 1 ) )
{
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
else
{
lDate = hb_pardl( 1 );
}
if( lDate != 0 )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
hb_retd( iYear, iMonth, 1 );
}
else
{
hb_retdl( 0 );
}
}
| datetime.c | 101 |
HB_FUNC | EOM(void)
HB_FUNC( EOM )
{
LONG lDate;
int iYear, iMonth, iDay;
if( ISNIL( 1 ) )
{
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
else
{
lDate = hb_pardl( 1 );
}
if( lDate != 0 )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
iMonth++;
if( iMonth > 12 )
{
iMonth = 1;
iYear++;
}
hb_retdl( hb_dateEncode( iYear, iMonth, 1 ) - 1 );
}
else
{
hb_retdl( 0 );
}
}
| datetime.c | 156 |
HB_FUNC | BOQ(void)
HB_FUNC( BOQ )
{
LONG lDate;
int iYear, iMonth, iDay;
if( ISNIL( 1 ) )
{
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
else
{
lDate = hb_pardl( 1 );
}
if( lDate != 0 )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
iMonth -= ( iMonth - 1 ) % 3;
hb_retd( iYear, iMonth, 1 );
}
else
{
hb_retdl( 0 );
}
}
| datetime.c | 217 |
HB_FUNC | EOQ(void)
HB_FUNC( EOQ )
{
LONG lDate;
int iYear, iMonth, iDay;
if( ISNIL( 1 ) )
{
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
else
{
lDate = hb_pardl( 1 );
}
if( lDate != 0 )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
iMonth += 3 - ( ( iMonth - 1 ) % 3 );
if( iMonth > 12 )
{
iMonth = 1;
iYear++;
}
hb_retdl( hb_dateEncode( iYear, iMonth, 1 ) - 1 );
}
else
{
hb_retdl( 0 );
}
}
| datetime.c | 274 |
HB_FUNC | BOY(void)
HB_FUNC( BOY )
{
LONG lDate;
int iYear, iMonth, iDay;
if( ISNIL( 1 ) )
{
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
else
{
lDate = hb_pardl( 1 );
}
if( lDate != 0 )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
hb_retd( iYear, 1, 1 );
}
else
{
hb_retdl( 0 );
}
}
| datetime.c | 336 |
HB_FUNC | EOY(void)
HB_FUNC( EOY )
{
LONG lDate;
int iYear, iMonth, iDay;
if( ISNIL( 1 ) )
{
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
else
{
lDate = hb_pardl( 1 );
}
if( lDate != 0 )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
hb_retdl( hb_dateEncode( iYear + 1, 1, 1 ) - 1 );
}
else
{
hb_retdl( 0 );
}
}
| datetime.c | 391 |
STATIC INT | hb_wom( int iYear, int iMonth, int iDay )
static int hb_wom( int iYear, int iMonth, int iDay )
{
int iWom;
HB_TRACE( HB_TR_DEBUG, ( "hb_wom(%d, %d, %d)", iYear, iMonth, iDay ) );
iWom = iDay + hb_dateDOW( iYear, iMonth, 1 ) - 1;
if( iWom > 0 )
return ( iWom - hb_dateDOW( iYear, iMonth, iDay ) ) / 7 + 1;
else
return 0;
}
| datetime.c | 418 |
HB_FUNC | WOM(void)
HB_FUNC( WOM )
{
LONG lDate;
int iYear, iMonth, iDay;
if( ISNIL( 1 ) )
{
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
else
{
lDate = hb_pardl( 1 );
}
if( lDate != 0 )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
hb_retni( hb_wom( iYear, iMonth, iDay ) );
}
else
{
hb_retni( 0 );
}
}
/* $DOC$
* $FUNCNAME$
* STOD()
* $CATEGORY$
* CT3 date and time functions
* $ONELINER$
* Convert ANSI date string to Harbour date
* $SYNTAX$
* STOD ([]) -> dDate
* $ARGUMENTS$
* $RETURNS$
* $DESCRIPTION$
* TODO: add documentation
* $EXAMPLES$
* $TESTS$
* $STATUS$
* Started
* $COMPLIANCE$
* STOD() is compatible with CT3's STOD().
* $PLATFORMS$
* All
* $FILES$
* Source is datetime.prg, library is libct.
* $SEEALSO$
* $END$
*/
| datetime.c | 431 |
HB_FUNC | STOD(void)
HB_FUNC( STOD )
{
hb_retds( hb_parclen( 1 ) >= 7 ? hb_parc( 1 ) : NULL );
}
| datetime.c | 487 |
dattime2.c |
Type | Function | Source | Line |
STATIC BOOL | ct_isleap( int iYear )
static BOOL ct_isleap( int iYear )
{
return ( ( ( iYear & 3 ) == 0 && iYear % 100 != 0 ) || iYear % 400 == 0 );
}
| dattime2.c | 73 |
STATIC INT | ct_daysinmonth( int iMonth, BOOL bLeap )
static int ct_daysinmonth( int iMonth, BOOL bLeap )
{
if( iMonth == 2 )
{
return ( bLeap ? 29 : 28 );
}
else if( iMonth == 4 || iMonth == 6 || iMonth == 9 || iMonth == 11 )
{
return ( 30 );
}
else
{
return ( 31 );
}
}
| dattime2.c | 78 |
STATIC INT | ct_daystomonth( int iMonth, BOOL bLeap )
static int ct_daystomonth( int iMonth, BOOL bLeap )
{
static const int iMonthes[] =
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
return ( ( iMonth < 1 && iMonth > 12 ) ? 0 : iMonthes[iMonth - 1] +
( ( bLeap && iMonth > 2 ) ? 1 : 0 ) );
}
| dattime2.c | 94 |
STATIC INT | ct_doy( LONG lDate )
static int ct_doy( LONG lDate )
{
int iYear, iMonth, iDay;
LONG lFirst;
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
lFirst = hb_dateEncode( iYear, 1, 1 );
return ( int ) ( lDate - lFirst + 1 );
}
| dattime2.c | 103 |
HB_FUNC | CTODOW(void)
HB_FUNC( CTODOW )
{
if( ISCHAR( 1 ) )
{
char *szParam = hb_parc( 1 ), *szDow;
int iDow, iEqual;
hb_strupr( szParam );
for( iDow = 0; iDow < 7; iDow++ )
{
szDow = hb_strdup( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_DAY + iDow ) );
hb_strupr( szDow );
if( hb_setGetL( HB_SET_EXACT ) )
{
iEqual = ( strlen( szDow ) == strlen( szParam ) )
&& !memcmp( szDow, szParam, strlen( szParam ) );
}
else
{
iEqual = !memcmp( szDow, szParam, strlen( szParam ) );
}
hb_xfree( szDow );
if( iEqual )
{
break;
}
}
if( iDow == 7 )
{
hb_retni( 0 );
}
else
{
hb_retnl( iDow + 1 );
}
}
else
{
hb_retni( 0 );
}
}
| dattime2.c | 114 |
HB_FUNC | CTOMONTH(void)
HB_FUNC( CTOMONTH )
{
if( ISCHAR( 1 ) )
{
char *szParam = hb_parc( 1 ), *szMonth;
int iMonth, iEqual;
hb_strupr( szParam );
for( iMonth = 1; iMonth <= 12; iMonth++ )
{
szMonth = hb_strdup( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_MONTH + iMonth - 1 ) );
hb_strupr( szMonth );
if( hb_setGetL( HB_SET_EXACT ) )
{
iEqual = ( strlen( szMonth ) == strlen( szParam ) )
&& !memcmp( szMonth, szParam, strlen( szParam ) );
}
else
{
iEqual = !memcmp( szMonth, szParam, strlen( szParam ) );
}
hb_xfree( szMonth );
if( iEqual )
{
break;
}
}
if( iMonth > 12 )
{
iMonth = 0;
}
hb_retnl( iMonth );
}
else
{
hb_retni( 0 );
}
}
| dattime2.c | 189 |
HB_FUNC | DMY(void)
HB_FUNC( DMY )
{
int iYear, iMonth, iDay;
BOOL bMode = FALSE;
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
}
else
{
hb_dateToday( &iYear, &iMonth, &iDay );
}
if( ISLOG( 2 ) )
{
bMode = hb_parl( 2 );
}
if( iMonth >= 1 && iMonth <= 12 )
{
char *szMonth = ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_MONTH + iMonth - 1 );
int iMonLen = strlen( szMonth );
int iLen = 0, iBufLen = iMonLen + 10;
char *szMDY = ( char * ) hb_xgrab( iBufLen );
if( iDay < 10 )
{
szMDY[iLen] = iDay + 0x30;
iLen++;
}
else
{
snprintf( szMDY + iLen, 3, "%02d", iDay );
iLen += 2;
}
if( bMode )
{
szMDY[iLen] = '.';
iLen++;
}
szMDY[iLen] = ' ';
iLen++;
hb_strncpy( szMDY + iLen, szMonth, iBufLen - iLen - 1 );
iLen += iMonLen;
szMDY[iLen] = ' ';
iLen++;
if( hb_setGetCentury() )
{
snprintf( szMDY + iLen, 5, "%04d", iYear );
iLen += 4;
}
else
{
snprintf( szMDY + iLen, 3, "%02d", iYear % 100 );
iLen += 2;
}
hb_retclen( szMDY, iLen );
hb_xfree( szMDY );
}
else
{
hb_retc( NULL );
}
}
| dattime2.c | 261 |
HB_FUNC | MDY(void)
HB_FUNC( MDY )
{
int iYear, iMonth, iDay;
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
}
else
{
hb_dateToday( &iYear, &iMonth, &iDay );
}
if( iMonth >= 1 && iMonth <= 12 )
{
char *szMonth = ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_MONTH + iMonth - 1 );
int iLen = strlen( szMonth );
int iBufLen = iLen + 9;
char *szMDY = ( char * ) hb_xgrab( iBufLen );
hb_strncpy( szMDY, szMonth, iBufLen - 1 );
szMDY[iLen++] = ' ';
if( iDay < 10 )
{
szMDY[iLen] = iDay + 0x30;
iLen++;
}
else
{
snprintf( szMDY + iLen, 3, "%02d", iDay );
iLen += 2;
}
szMDY[iLen++] = ' ';
if( hb_setGetCentury() )
{
snprintf( szMDY + iLen, 5, "%04d", iYear );
iLen += 4;
}
else
{
snprintf( szMDY + iLen, 3, "%02d", iYear % 100 );
iLen += 2;
}
hb_retclen( szMDY, iLen );
hb_xfree( szMDY );
}
else
{
hb_retc( NULL );
}
}
| dattime2.c | 363 |
HB_FUNC | ADDMONTH(void)
HB_FUNC( ADDMONTH )
{
int iYear, iMonth, iDay, iNum, iDays;
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
iNum = hb_parni( 2 );
}
else if( ISNUM( 1 ) )
{
iNum = hb_parni( 1 );
hb_dateToday( &iYear, &iMonth, &iDay );
}
else
{
hb_retdl( 0 );
return;
}
iMonth += iNum;
while( iMonth <= 0 )
{
iMonth += 12;
iYear--;
}
while( iMonth > 12 )
{
iMonth -= 12;
iYear++;
}
iDays = ct_daysinmonth( iMonth, ct_isleap( iYear ) );
if( iDay > iDays )
{
iDay = iDays;
}
hb_retd( iYear, iMonth, iDay );
}
| dattime2.c | 476 |
HB_FUNC | DOY(void)
HB_FUNC( DOY )
{
LONG lDate;
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
if( pDate )
{
lDate = hb_itemGetDL( pDate );
}
else
{
int iYear, iMonth, iDay;
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
hb_retni( ct_doy( lDate ) );
}
| dattime2.c | 520 |
HB_FUNC | ISLEAP(void)
HB_FUNC( ISLEAP )
{
int iYear, iMonth, iDay;
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
if( pDate && hb_itemGetDL( pDate ) )
{
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
}
else
{
hb_dateToday( &iYear, &iMonth, &iDay );
}
hb_retl( ct_isleap( iYear ) );
}
| dattime2.c | 569 |
HB_FUNC | DAYSTOMONTH(void)
HB_FUNC( DAYSTOMONTH )
{
int iMonth = ( ISNUM( 1 ) ? hb_parni( 1 ) : 0 );
BOOL bLeap = ( ISLOG( 2 ) ? hb_parl( 2 ) : 0 );
hb_retni( ct_daystomonth( iMonth, bLeap ) );
}
| dattime2.c | 613 |
HB_FUNC | DAYSINMONTH(void)
HB_FUNC( DAYSINMONTH )
{
int iMonth = ( ISNUM( 1 ) ? hb_parni( 1 ) : 0 );
BOOL bLeap = ( ISLOG( 2 ) ? hb_parl( 2 ) : 0 );
hb_retni( ct_daysinmonth( iMonth, bLeap ) );
}
| dattime2.c | 651 |
HB_FUNC | QUARTER(void)
HB_FUNC( QUARTER )
{
int iYear, iMonth, iDay;
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
if( pDate )
{
if( hb_itemGetDL( pDate ) )
{
hb_dateDecode( hb_itemGetDL( pDate ), &iYear, &iMonth, &iDay );
}
else
{
hb_retni( 0 );
return;
}
}
else
{
hb_dateToday( &iYear, &iMonth, &iDay );
}
hb_retni( ( iMonth + 2 ) / 3 );
}
| dattime2.c | 688 |
HB_FUNC | LASTDAYOM(void)
HB_FUNC( LASTDAYOM )
{
BOOL bLeap = 0;
int iYear, iMonth, iDay;
if( ISDATE( 1 ) )
{
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
LONG lDate = hb_itemGetDL( pDate );
if( lDate )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
}
else
{
hb_dateToday( &iYear, &iMonth, &iDay );
}
bLeap = ct_isleap( iYear );
}
else if( ISNUM( 1 ) )
{
iMonth = hb_parni( 1 );
}
else
{
iMonth = 0;
}
hb_retni( ( iMonth && ( iMonth <= 12 ) ? ct_daysinmonth( iMonth, bLeap ) : 0 ) );
}
| dattime2.c | 742 |
HB_FUNC | NTOCDOW(void)
HB_FUNC( NTOCDOW )
{
hb_retc( hb_dateCDOW( hb_parni( 1 ) ) );
}
| dattime2.c | 806 |
HB_FUNC | NTOCMONTH(void)
HB_FUNC( NTOCMONTH )
{
hb_retc( hb_dateCMonth( hb_parni( 1 ) ) );
}
| dattime2.c | 839 |
HB_FUNC | WEEK(void)
HB_FUNC( WEEK )
{
int iYear, iMonth, iDay, iWeek;
PHB_ITEM pDate = hb_param( 1, HB_IT_DATE );
LONG lDate = 0;
BOOL bSWN = ( ISLOG( 2 ) ? hb_parl( 2 ) : FALSE );
if( ISDATE( 1 ) )
{
lDate = hb_itemGetDL( pDate );
if( !lDate )
{
hb_retni( 0 );
return;
}
}
if( lDate )
{
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
}
else
{
hb_dateToday( &iYear, &iMonth, &iDay );
lDate = hb_dateEncode( iYear, iMonth, iDay );
}
if( bSWN )
{
int iDays = ct_daystomonth( iMonth, ct_isleap( iYear ) ) + iDay;
int iPart = ( iDays % 7 );
iWeek = iDays / 7;
if( iPart > 0 )
iWeek++;
}
else
{
LONG lDate2;
if( hb_setGetCPtr( HB_SET_DATEFORMAT ) && ( hb_setGetCPtr( HB_SET_DATEFORMAT )[0] == 'd' ||
hb_setGetCPtr( HB_SET_DATEFORMAT )[0] == 'D' ) )
lDate2 = lDate + 3 - ( hb_dateDOW( iYear, iMonth, iDay ) + 5 ) % 7;
else
lDate2 = lDate + 4 - hb_dateDOW( iYear, iMonth, iDay );
iWeek = ( ct_doy( lDate2 ) - 1 ) / 7 + 1;
}
hb_retni( iWeek );
}
| dattime2.c | 872 |
dattime3.c |
Type | Function | Source | Line |
HB_FUNC | WAITPERIOD(void)
HB_FUNC( WAITPERIOD )
{
double d = hb_dateSeconds();
if( hb_pcount() > 0 )
{
s_dTimeSet = d;
s_dTimeCounter = d + hb_parnd( 1 ) / 100.0;
}
if( d < s_dTimeSet )
d += 86400.0;
hb_retl( d < s_dTimeCounter );
}
| dattime3.c | 124 |
STATIC BOOL | _hb_timeValid( char * szTime, ULONG ulLen, int * piDecode )
static BOOL _hb_timeValid( char * szTime, ULONG ulLen, int * piDecode )
{
BOOL fValid = FALSE;
if( ulLen == 2 || ulLen == 5 || ulLen == 8 || ulLen == 11 )
{
static const int s_iMax[] = { 23, 59, 59, 99 };
int i, iVal;
ULONG ul;
fValid = TRUE;
for( ul = 0; fValid && ul < ulLen; ++ul )
{
fValid = ul % 3 == 2 ? szTime[ul] == ':' :
( szTime[ul] >= '0' && szTime[ul] <= '9' );
}
for( ul = 0, i = 0; fValid && ul < ulLen; ul += 3, ++i )
{
iVal = 10 * ( szTime[ul] - '0' ) + ( szTime[ul + 1] - '0' );
fValid = iVal <= s_iMax[i];
if( piDecode )
piDecode[i] = iVal;
}
}
return fValid;
}
| dattime3.c | 140 |
HB_FUNC | TIMEVALID(void)
HB_FUNC( TIMEVALID )
{
hb_retl( _hb_timeValid( hb_parc( 1 ), hb_parclen( 1 ), NULL ) );
}
| dattime3.c | 229 |
HB_FUNC | SETTIME(void)
HB_FUNC( SETTIME )
{
BOOL fResult = FALSE;
int iTime[4];
iTime[0] = iTime[1] = iTime[2] = iTime[3] = 0;
if( _hb_timeValid( hb_parc( 1 ), hb_parclen( 1 ), iTime ) )
{
#if defined(HB_OS_WIN_32)
SYSTEMTIME st;
GetLocalTime( &st );
st.wHour = iTime[0];
st.wMinute = iTime[1];
st.wSecond = iTime[2];
st.wMilliseconds = iTime[3] * 10;
fResult = SetLocalTime( &st );
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
/* stime exists only in SVr4, SVID, X/OPEN and Linux */
ULONG lNewTime;
time_t tm;
lNewTime = iTime[0] * 3600 + iTime[1] * 60 + iTime[2];
tm = time( NULL );
tm += lNewTime - ( tm % 86400 );
fResult = stime( &tm ) == 0;
#endif
}
hb_retl( fResult );
}
| dattime3.c | 286 |
HB_FUNC | SETDATE(void)
HB_FUNC( SETDATE )
{
BOOL fResult = FALSE;
long lDate = hb_pardl( 1 );
if( lDate )
{
int iYear, iMonth, iDay;
hb_dateDecode( lDate, &iYear, &iMonth, &iDay );
if( iYear >= 1970 )
{
#if defined(HB_OS_WIN_32)
SYSTEMTIME st;
GetLocalTime( &st );
st.wYear = iYear;
st.wMonth = iMonth;
st.wDay = iDay;
st.wDayOfWeek = hb_dateJulianDOW( lDate );
fResult = SetLocalTime( &st );
#elif defined( HB_OS_LINUX ) && !defined( __WATCOMC__ )
/* stime exists only in SVr4, SVID, X/OPEN and Linux */
long lNewDate;
time_t tm;
lNewDate = lDate - hb_dateEncode( 1970, 1, 1 );
tm = time( NULL );
tm = lNewDate * 86400 + ( tm % 86400 );
fResult = stime( &tm ) == 0;
#endif
}
}
hb_retl( fResult );
}
| dattime3.c | 368 |
dbftools.c |
Type | Function | Source | Line |
HB_FUNC | FIELDSIZE(void)
HB_FUNC( FIELDSIZE )
{
HB_FUNC_EXEC( FIELDLEN );
}
| dbftools.c | 63 |
HB_FUNC | FIELDDECI(void)
HB_FUNC( FIELDDECI )
{
HB_FUNC_EXEC( FIELDDEC );
}
| dbftools.c | 68 |
HB_FUNC | FIELDNUM(void)
HB_FUNC( FIELDNUM )
{
HB_FUNC_EXEC( FIELDPOS );
}
| dbftools.c | 73 |
HB_FUNC | DBFSIZE(void)
HB_FUNC( DBFSIZE )
{
HB_LONG llSize = 0;
AREAP pArea;
if( ( pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer() ) != NULL )
{
PHB_ITEM pSize = hb_itemNew( NULL );
ULONG ulRecSize, ulRecCount;
if( SELF_INFO( pArea, DBI_GETHEADERSIZE, pSize ) == SUCCESS )
{
llSize = hb_itemGetNL( pSize ) + 1;
if( SELF_INFO( pArea, DBI_GETRECSIZE, pSize ) == SUCCESS )
{
ulRecSize = hb_itemGetNL( pSize );
if( SELF_RECCOUNT( pArea, &ulRecCount ) == SUCCESS )
{
llSize += ( HB_LONG ) ulRecCount *ulRecSize;
}
}
}
hb_itemRelease( pSize );
}
hb_retnint( llSize );
}
| dbftools.c | 78 |
disk.c |
Type | Function | Source | Line |
HB_FUNC | DIRMAKE(void)
HB_FUNC( DIRMAKE )
{
BYTE *pFileName = ( BYTE * ) hb_parcx( 1 );
if( hb_fsMkDir( pFileName ) )
{
hb_retni( 0 );
}
else
{
hb_retni( -hb_fsOsError() );
}
}
| disk.c | 87 |
HB_FUNC | DIRNAME(void)
HB_FUNC( DIRNAME )
{
BYTE *pbyBuffer = ( BYTE * ) hb_xgrab( _POSIX_PATH_MAX + 1 );
pbyBuffer[0] = OS_PATH_DELIMITER;
hb_fsCurDirBuff( hb_fsCurDrv(), pbyBuffer + 1, _POSIX_PATH_MAX );
hb_retc_buffer( ( char * ) pbyBuffer );
}
| disk.c | 101 |
HB_FUNC | DRIVETYPE(void)
HB_FUNC( DRIVETYPE )
{
#if defined(HB_OS_WIN_32)
ULONG ulSize = hb_parclen( 1 ) + 2; /* allow space for '\0' & ":\" */
char *pszDrive = ( char * ) hb_xgrab( ulSize + 1 );
LPTSTR lpDrive;
int iType;
hb_strncpy( pszDrive, ( char * ) hb_parcx( 1 ), ulSize );
if( strstr( pszDrive, ":" ) == NULL )
hb_strncat( pszDrive, ":", ulSize );
if( strstr( pszDrive, "\\" ) == NULL )
hb_strncat( pszDrive, "\\", ulSize );
lpDrive = HB_TCHAR_CONVTO( pszDrive );
switch( GetDriveType( lpDrive ) )
{
case DRIVE_RAMDISK:
iType = 0; /* RAM Drive - Clipper compatible */
break;
case DRIVE_REMOVABLE:
iType = 2; /* Floppy Drive - Clipper compatible */
break;
case DRIVE_FIXED:
iType = 3; /* Hard Drive - Clipper compatible */
break;
case DRIVE_CDROM:
iType = 4; /* CD-Rom Drive - xHarbour extension */
break;
case DRIVE_REMOTE:
iType = 5; /* Network Drive - xHarbour extension */
break;
default:
iType = 9; /* Unknow Drive - xHarbour extension */
break;
}
hb_retni( iType );
hb_xfree( pszDrive );
HB_TCHAR_FREE( lpDrive );
#else
hb_retni( 9 );
#endif
}
| disk.c | 112 |
HB_FUNC | NUMDISKL(void)
HB_FUNC( NUMDISKL )
{
#if defined( HB_OS_DOS )
#if defined( __DJGPP__ )
unsigned cur_drive, n_drives;
_dos_getdrive( &cur_drive );
_dos_setdrive( cur_drive, &n_drives );
hb_retni( n_drives );
#else
/* should be easily implementable somehow similar to DJGPP */
hb_retni( 26 );
#endif
#elif defined( HB_OS_WIN_32 )
/* LASTDRIVE does not affect Win32 apps, they always have 26 letters avail */
hb_retni( 26 );
#else
/* For Unix, return the most harmless value... or not? */
hb_retni( 1 );
#endif
}
| disk.c | 160 |
HB_FUNC | VOLUME(void)
HB_FUNC( VOLUME )
{
BOOL bReturn = FALSE;
if( !ct_getsafety() )
{
PHB_FNAME fname;
BYTE *sDiskName;
char *sRoot = NULL;
char *sVolName = NULL;
char sRootBuf[3], sVolNameBuf[12];
BOOL fFree;
if( ISCHAR( 1 ) && hb_parclen( 1 ) > 0 )
{
sDiskName = hb_fsNameConv( ( BYTE * ) hb_parc( 1 ), &fFree );
if( ( fname = hb_fsFNameSplit( ( char * ) sDiskName ) ) != NULL )
{
if( fname->szPath )
{
strncpy( sRootBuf, fname->szPath, 3 );
sRoot = sRootBuf;
}
if( fname->szName )
{
strncpy( sVolNameBuf, fname->szName, 11 );
sVolName = sVolNameBuf;
}
hb_xfree( fname );
}
else
{
strncpy( sVolNameBuf, ( char * ) sDiskName, 11 );
sVolName = sVolNameBuf;
}
if( fFree )
hb_xfree( sDiskName );
}
#if defined(HB_OS_WIN_32)
{
LPTSTR lpRoot, lpVolName;
lpRoot = sRoot ? HB_TCHAR_CONVTO( sRoot ) : NULL;
lpVolName = sVolName ? HB_TCHAR_CONVTO( sVolName ) : NULL;
bReturn = SetVolumeLabel( lpRoot, lpVolName );
if( lpRoot )
HB_TCHAR_FREE( lpRoot );
if( lpVolName )
HB_TCHAR_FREE( lpVolName );
}
#endif
}
hb_retl( bReturn );
}
| disk.c | 199 |
HB_FUNC | GETVOLINFO(void)
HB_FUNC( GETVOLINFO )
{
#if defined(HB_OS_WIN_32)
int iretval;
char *sDrive = hb_parcx( 1 ), *sVolName;
TCHAR lpVolName[256];
LPTSTR lpDrive;
lpDrive = sDrive[0] ? HB_TCHAR_CONVTO( sDrive ) : NULL;
iretval = GetVolumeInformation( lpDrive, lpVolName, 256, NULL, NULL, NULL, NULL, 0 );
if( lpDrive )
HB_TCHAR_FREE( lpDrive );
if( iretval != 0 )
{
sVolName = HB_TCHAR_CONVFROM( lpVolName );
hb_retc( sVolName );
HB_TCHAR_FREE( sVolName );
}
else
hb_retc( NULL );
#endif
}
| disk.c | 255 |
HB_FUNC | VOLSERIAL(void)
HB_FUNC( VOLSERIAL )
{
#if defined(HB_OS_WIN_32)
int retval;
char *sDrive = hb_parcx( 1 );
LPTSTR lpDrive;
DWORD dSerial;
lpDrive = sDrive[0] ? HB_TCHAR_CONVTO( sDrive ) : NULL;
retval = GetVolumeInformation( lpDrive, /* RootPathName */
NULL, /* VolumeName */
0, /* VolumeNameSize */
&dSerial, /* VolumeSerialNumber */
NULL, /* MaxComponentLength */
NULL, /* FileSystemFlags */
NULL, /* FileSystemName */
0 ); /* FileSystemSize */
if( lpDrive )
HB_TCHAR_FREE( lpDrive );
if( retval != 0 )
hb_retnint( dSerial );
else
hb_retni( -1 );
#endif
}
| disk.c | 298 |
HB_FUNC | TRUENAME(void)
HB_FUNC( TRUENAME )
{
char *szFile = hb_parc( 1 );
if( szFile )
{
#ifdef HB_OS_WIN_32
char *szBuffRet;
TCHAR buffer[MAX_PATH + 1] = { 0 };
LPTSTR lpFile;
lpFile = HB_TCHAR_CONVTO( szFile );
GetFullPathName( lpFile, MAX_PATH, buffer, NULL );
HB_TCHAR_FREE( lpFile );
szBuffRet = HB_TCHAR_CONVFROM( buffer );
hb_retc( szBuffRet );
HB_TCHAR_FREE( szBuffRet );
#else
hb_retc( szFile );
#endif
}
else
hb_retc( NULL );
}
| disk.c | 325 |
expand.c |
Type | Function | Source | Line |
HB_FUNC | EXPAND(void)
HB_FUNC( EXPAND )
{
ULONG ulLen = hb_parclen( 1 ), ulSize, ul;
if( ulLen > 0 )
{
char * szText = hb_parc( 1 );
if( ulLen == 1 )
hb_retclen( szText, 1 );
else
{
char * szDest, *szPtr, cRepl;
int iRepl, i;
iRepl = hb_parni( 2 );
i = hb_pcount();
if( i == 2 && ISCHAR( 2 ) )
{
iRepl = 1;
cRepl = hb_parc( 2 )[0];
}
else if( i == 2 && iRepl == 0 && ISNUM( 2 ) )
{
iRepl = 1;
cRepl = 0;
}
else
{
if( iRepl < 1 )
iRepl = 1;
if( ISNUM( 3 ) )
cRepl = ( char ) hb_parni( 3 );
else if( ISCHAR( 3 ) )
cRepl = hb_parc( 3 )[0];
else
cRepl = ' ';
}
ulSize = ( ulLen - 1 ) * ( iRepl + 1 ) + 1;
szPtr = szDest = ( char * ) hb_xgrab( ulSize + 1 );
*szPtr++ = szText[0];
for( ul = 1; ul < ulLen; ++ul )
{
for( i = 0; i < iRepl; ++i )
*szPtr++ = cRepl;
*szPtr++ = szText[ul];
}
hb_retclen_buffer( szDest, ulSize );
}
}
else
hb_retc( NULL );
}
| expand.c | 56 |
exponent.c |
Type | Function | Source | Line |
HB_FUNC | MANTISSA(void)
HB_FUNC( MANTISSA )
{
#ifdef CT_EXPONENT_MANTISSA_BIT
union
{
double value;
char string[sizeof( double )];
} xConvert;
xConvert.value = hb_parnd( 1 );
if( xConvert.value != 0 )
{
xConvert.string[6] |= 0xF0;
xConvert.string[7] |= 0x3F;
xConvert.string[7] &= 0xBF;
}
hb_retnd( xConvert.value );
#else
double dValue;
dValue = hb_parnd( 1 );
if( dValue == 0.0 )
{
hb_retnd( 0.0 );
return;
}
if( fabs( dValue ) < 1.0 )
{
while( fabs( dValue ) < 1.0 )
dValue *= 2.0;
}
else if( fabs( dValue ) >= 2.0 )
{
while( fabs( dValue ) >= 2.0 )
dValue /= 2.0;
}
hb_retnd( dValue );
#endif
}
| exponent.c | 99 |
HB_FUNC | EXPONENT(void)
HB_FUNC( EXPONENT )
{
#ifdef CT_EXPONENT_MANTISSA_BIT
int iExponent = 0;
union
{
double value;
char string[sizeof( double )];
} xConvert;
xConvert.value = hb_parnd( 1 );
if( xConvert.value != 0 )
{
iExponent = ( int ) ( xConvert.string[7] & 0x07F );
iExponent = iExponent << 4;
iExponent += ( int ) ( ( xConvert.string[6] & 0xF0 ) >> 4 );
iExponent -= 1023;
}
hb_retni( iExponent );
#else
int iExponent = 0;
double dValue;
dValue = hb_parnd( 1 );
if( dValue == 0.0 )
{
hb_retni( 0 );
return;
}
if( fabs( dValue ) < 1.0 )
{
while( fabs( dValue ) < 1.0 )
{
dValue *= 2.0;
iExponent--;
}
}
else if( fabs( dValue ) >= 2.0 )
{
while( fabs( dValue ) >= 2.0 )
{
dValue /= 2.0;
iExponent++;
}
}
hb_retni( iExponent );
#endif
}
| exponent.c | 195 |
files.c |
Type | Function | Source | Line |
STATIC VOID | _hb_fileClose( void * cargo )
static void _hb_fileClose( void * cargo )
{
HB_SYMBOL_UNUSED( cargo );
if( s_ffind )
{
hb_fsFindClose( s_ffind );
s_ffind = NULL;
}
}
| files.c | 100 |
STATIC PHB_FFIND | _hb_fileStart( BOOL fNext, ULONG ulAttr )
static PHB_FFIND _hb_fileStart( BOOL fNext, ULONG ulAttr )
{
if( hb_pcount() > 0 )
{
char * szFile = hb_parc( 1 );
BOOL fFree;
if( s_ffind )
{
hb_fsFindClose( s_ffind );
s_ffind = NULL;
}
if( szFile )
{
if( !s_fInit )
{
hb_vmAtExit( _hb_fileClose, NULL );
s_fInit = TRUE;
}
szFile = ( char * ) hb_fsNameConv( ( BYTE * ) szFile, &fFree );
if( ISNUM( 2 ) )
ulAttr = ( ULONG ) hb_parnl( 2 );
s_ulAttr = ISLOG( 3 ) && hb_parl( 3 ) ? ulAttr : 0;
s_ffind = hb_fsFindFirst( szFile, ulAttr );
if( fFree )
hb_xfree( szFile );
while( s_ffind && s_ulAttr && s_ffind->attr != s_ulAttr )
{
if( !hb_fsFindNext( s_ffind ) )
{
hb_fsFindClose( s_ffind );
s_ffind = NULL;
}
}
}
}
else if( fNext && s_ffind )
{
do
{
if( !hb_fsFindNext( s_ffind ) )
{
hb_fsFindClose( s_ffind );
s_ffind = NULL;
break;
}
}
while( s_ulAttr && s_ffind->attr != s_ulAttr );
}
return s_ffind;
}
| files.c | 111 |
HB_FUNC | FILESEEK(void)
HB_FUNC( FILESEEK )
{
PHB_FFIND ffind = _hb_fileStart( TRUE, HB_FA_ALL );
hb_retc( ffind ? ffind->szName : NULL );
}
| files.c | 165 |
HB_FUNC | FILEATTR(void)
HB_FUNC( FILEATTR )
{
/* CT3 uses 64 as attribute mask but the idea was setting ALL
* attributes and because we are supporting more attributes
* then I decided to use 0xffff value. [druzus]
*/
PHB_FFIND ffind = _hb_fileStart( FALSE, 0xffff );
hb_retni( ffind ? ffind->attr : 0 );
}
| files.c | 172 |
HB_FUNC | FILESIZE(void)
HB_FUNC( FILESIZE )
{
PHB_FFIND ffind = _hb_fileStart( FALSE, HB_FA_ALL );
hb_retnint( ffind ? ffind->size : -1 );
}
| files.c | 183 |
HB_FUNC | FILEDATE(void)
HB_FUNC( FILEDATE )
{
PHB_FFIND ffind = _hb_fileStart( FALSE, HB_FA_ALL );
hb_retdl( ffind ? ffind->lDate : 0 );
}
| files.c | 190 |
HB_FUNC | FILETIME(void)
HB_FUNC( FILETIME )
{
PHB_FFIND ffind = _hb_fileStart( FALSE, HB_FA_ALL );
hb_retc( ffind ? ffind->szTime : NULL );
}
| files.c | 197 |
HB_FUNC | SETFATTR(void)
HB_FUNC( SETFATTR )
{
int iResult;
if( hb_fsSetAttr( ( BYTE * ) hb_parcx( 1 ),
ISNUM( 2 ) ? hb_parnl( 2 ) : HB_FA_ARCHIVE ) )
iResult = 0;
else
iResult = -1;
hb_retni( iResult );
}
| files.c | 205 |
HB_FUNC | SETFDATI(void)
HB_FUNC( SETFDATI )
{
if( hb_pcount() >= 1 )
{
PHB_ITEM pDate, pTime;
char *szFile = hb_parcx( 1 );
int year = 0, month = 0, day = 0, hour = 0, minute = 0, second = 0;
pDate = hb_param( 2, HB_IT_DATE );
if( !pDate )
pDate = hb_param( 3, HB_IT_DATE );
if( pDate )
hb_dateDecode( hb_itemGetDL( pDate ), &year, &month, &day );
pTime = hb_param( 2, HB_IT_STRING );
if( !pTime )
pTime = hb_param( 3, HB_IT_STRING );
if( pTime )
hb_timeStrGet( hb_itemGetCPtr( pTime ), &hour, &minute, &second, NULL );
#if defined( HB_OS_WIN_32 ) && !defined( __CYGWIN__ )
{
FILETIME ft, local_ft;
SYSTEMTIME st;
HANDLE f = ( HANDLE ) _lopen( szFile, OF_READWRITE | OF_SHARE_COMPAT );
if( f != ( HANDLE ) HFILE_ERROR )
{
if( !pDate || !pTime )
GetLocalTime( &st );
if( pDate )
{
st.wYear = year;
st.wMonth = month;
st.wDay = day;
}
if( pTime )
{
st.wHour = hour;
st.wMinute = minute;
st.wSecond = second;
}
SystemTimeToFileTime( &st, &local_ft );
LocalFileTimeToFileTime( &local_ft, &ft );
hb_retl( SetFileTime( f, NULL, &ft, &ft ) );
_lclose( ( HFILE ) f );
return;
}
}
#elif defined( HB_OS_OS2 )
{
FILESTATUS3 fs3;
APIRET ulrc;
ulrc = DosQueryPathInfo( szFile, FIL_STANDARD, &fs3, sizeof( fs3 ) );
if( ulrc == NO_ERROR )
{
FDATE fdate;
FTIME ftime;
if( !pDate || !pTime )
{
DATETIME dt;
DosGetDateTime( &dt );
fdate.year = dt.year - 1980;
fdate.month = dt.month;
fdate.day = dt.day;
ftime.hours = dt.hours;
ftime.minutes = dt.minutes;
ftime.twosecs = dt.seconds / 2;
}
if( pDate )
{
fdate.year = year - 1980;
fdate.month = month;
fdate.day = day;
}
if( pTime )
{
ftime.hours = hour;
ftime.minutes = minute;
ftime.twosecs = second / 2;
}
fs3.fdateCreation = fs3.fdateLastAccess = fs3.fdateLastWrite = fdate;
fs3.ftimeCreation = fs3.ftimeLastAccess = fs3.ftimeLastWrite = ftime;
ulrc = DosSetPathInfo( szFile, FIL_STANDARD,
&fs3, sizeof( fs3 ), DSPI_WRTTHRU );
}
hb_retl( ulrc == NO_ERROR );
return;
}
#elif defined( OS_UNIX_COMPATIBLE ) || defined( __DJGPP__ )
if( !pDate && !pTime )
{
hb_retl( utime( szFile, NULL ) == 0 );
return;
}
else
{
struct utimbuf buf;
struct tm new_value;
if( !pDate || !pTime )
{
time_t current_time;
current_time = time( NULL );
# if _POSIX_C_SOURCE < 199506L || defined( HB_OS_DARWIN_5 )
new_value = *localtime( ¤t_time );
# else
localtime_r( ¤t_time, &new_value );
# endif
}
else
memset( &new_value, 0, sizeof( new_value ) );
if( pDate )
{
new_value.tm_year = year - 1900;
new_value.tm_mon = month - 1;
new_value.tm_mday = day;
}
if( pTime )
{
new_value.tm_hour = hour;
new_value.tm_min = minute;
new_value.tm_sec = second;
}
buf.actime = buf.modtime = mktime( &new_value );
hb_retl( utime( szFile, &buf ) == 0 );
return;
}
#else
int TODO; /* To force warning */
#endif
}
hb_retl( FALSE );
}
| files.c | 219 |
HB_FUNC | FILEDELETE(void)
HB_FUNC( FILEDELETE )
{
BOOL bReturn = FALSE;
if( ISCHAR( 1 ) )
{
BYTE * pDirSpec;
PHB_FFIND ffind;
ULONG ulAttr = HB_FA_ALL;
BOOL fFree;
pDirSpec = hb_fsNameConv( ( BYTE * ) hb_parc( 1 ), &fFree );
if( ISNUM( 2 ) )
ulAttr = hb_parnl( 2 );
if( ( ffind = hb_fsFindFirst( ( char * ) pDirSpec, ulAttr ) ) != NULL )
{
PHB_FNAME pFilepath;
pFilepath = hb_fsFNameSplit( ( char * ) pDirSpec );
pFilepath->szExtension = NULL;
do
{
char szPath[ _POSIX_PATH_MAX + 1 ];
pFilepath->szName = ffind->szName;
hb_fsFNameMerge( szPath, pFilepath );
if( hb_fsDelete( ( BYTE * ) szPath ) )
bReturn = TRUE;
}
while( hb_fsFindNext( ffind ) );
hb_xfree( pFilepath );
hb_fsFindClose( ffind );
}
if( fFree )
hb_xfree( pDirSpec );
}
hb_retl( bReturn );
}
| files.c | 366 |
HB_FUNC | FILEMOVE(void)
HB_FUNC( FILEMOVE )
{
hb_retni( hb_fsRename( ( BYTE * ) hb_parcx( 1 ),
( BYTE * ) hb_parcx( 2 ) ) ? 0 : -hb_fsOsError() );
}
| files.c | 411 |
HB_FUNC | RENAMEFILE(void)
HB_FUNC( RENAMEFILE )
{
HB_FUNC_EXEC( FILEMOVE );
}
| files.c | 418 |
HB_FUNC | DELETEFILE(void)
HB_FUNC( DELETEFILE )
{
hb_retni( hb_fsDelete( ( BYTE * ) hb_parcx( 1 ) ) ? 0 : -hb_fsOsError() );
}
| files.c | 424 |
HB_FUNC | FILESMAX(void)
HB_FUNC( FILESMAX )
{
#if defined( __DJGPP__ )
__dpmi_regs r;
unsigned handles;
ULONG psp;
r.h.ah = 0x62; /* Get PSP address */
__dpmi_int( 0x21, &r );
psp = ( ( ( ULONG ) r.x.bx ) << 4 ) & 0xFFFFF;
handles = _farpeekw( _dos_ds, psp + 0x32 );
hb_retni( handles );
#elif defined( _SC_OPEN_MAX )
hb_retnl( sysconf( _SC_OPEN_MAX ) );
#else
hb_retni( -1 );
#endif
}
| files.c | 430 |
finan.c |
Type | Function | Source | Line |
HB_FUNC | FV(void)
HB_FUNC( FV )
{
if( ISNUM( 1 ) && ISNUM( 2 ) && ISNUM( 3 ) )
{
double dPayment = hb_parnd( 1 );
double dRate = hb_parnd( 2 );
double dTime = hb_parnd( 3 );
double dResult;
if( dRate == 0.0 )
{
/* NOTE: CT3 crashes with dRate == 0.0 */
dResult = dPayment * dTime;
}
else
{
HB_MATH_EXCEPTION hb_exc;
double dBase = 1.0 + dRate;
hb_mathResetError( &hb_exc );
dResult = pow( dBase, dTime );
if( hb_mathGetError( &hb_exc, "POW", dBase, dTime, dResult ) )
{
dResult = hb_exc.handled ? hb_exc.retval : 0.0;
}
dResult = dPayment * ( dResult - 1.0 ) / dRate;
}
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_FV, NULL, "FV", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| finan.c | 120 |
HB_FUNC | PV(void)
HB_FUNC( PV )
{
if( ISNUM( 1 ) && ISNUM( 2 ) && ISNUM( 3 ) )
{
double dPayment = hb_parnd( 1 );
double dRate = hb_parnd( 2 );
double dTime = hb_parnd( 3 );
double dResult;
if( dRate == 0.0 )
{
/* NOTE: CT3 crashes with dRate == 0.0 */
dResult = dPayment * dTime;
}
else
{
HB_MATH_EXCEPTION hb_exc;
double dBase = 1.0 + dRate;
hb_mathResetError( &hb_exc );
dResult = pow( dBase, -dTime );
if( hb_mathGetError( &hb_exc, "POW", dBase, -dTime, dResult ) )
{
dResult = hb_exc.handled ? hb_exc.retval : 0.0;
}
dResult = dPayment * ( 1.0 - dResult ) / dRate;
}
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_PV, NULL, "PV", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| finan.c | 221 |
HB_FUNC | PAYMENT(void)
HB_FUNC( PAYMENT )
{
if( ISNUM( 1 ) && ISNUM( 2 ) && ISNUM( 3 ) )
{
double dCapital = hb_parnd( 1 );
double dRate = hb_parnd( 2 );
double dTime = hb_parnd( 3 );
double dResult;
if( dRate == 0.0 )
{
/* NOTE: CT3 crashes with dRate == 0.0 */
dResult = dCapital / dTime;
}
else
{
HB_MATH_EXCEPTION hb_exc;
double dBase = 1.0 + dRate;
hb_mathResetError( &hb_exc );
dResult = pow( dBase, -dTime );
if( hb_mathGetError( &hb_exc, "POW", dBase, -dTime, dResult ) )
{
dResult = hb_exc.handled ? hb_exc.retval : 0.0;
}
dResult = dCapital * dRate / ( 1.0 - dResult );
}
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_PAYMENT, NULL, "PAYMENT", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| finan.c | 320 |
HB_FUNC | PERIODS(void)
HB_FUNC( PERIODS )
{
if( ISNUM( 1 ) && ISNUM( 2 ) && ISNUM( 3 ) )
{
double dCapital = hb_parnd( 1 );
double dPayment = hb_parnd( 2 );
double dRate = hb_parnd( 3 );
double dResult;
if( dPayment <= dCapital * dRate )
{
/* in this case infinite time is needed to cancel the loan */
dResult = -1.0;
}
else if( dRate == 0.0 )
{
/* NOTE: CT3 crashes with dRate == 0.0 */
dResult = dCapital / dPayment;
}
else
{
HB_MATH_EXCEPTION hb_exc;
double dBase = 1.0 + dRate;
hb_mathResetError( &hb_exc );
dResult = log( dBase );
if( hb_mathGetError( &hb_exc, "LOG", dBase, 0.0, dResult ) )
{
dResult = hb_exc.handled ? hb_exc.retval : 0.0;
}
if( dResult )
{
double dResult2;
hb_mathResetError( &hb_exc );
dBase = 1.0 - ( dCapital * dRate / dPayment );
dResult2 = log( dBase );
if( hb_mathGetError( &hb_exc, "LOG", dBase, 0.0, dResult2 ) )
{
dResult2 = hb_exc.handled ? hb_exc.retval : 0.0;
}
dResult = -dResult2 / dResult;
}
}
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_PERIODS, NULL, "PERIODS", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| finan.c | 424 |
HB_FUNC | RATE(void)
HB_FUNC( RATE )
{
if( ISNUM( 1 ) && ISNUM( 2 ) && ISNUM( 3 ) )
{
double dCapital = hb_parnd( 1 );
double dPayment = hb_parnd( 2 );
double dTime = hb_parnd( 3 );
double dAux; /* estimated payment to compare for */
double dEpsilon = 0.00001; /* mimimal to consider 2 numbers as equal */
double dScale = 1.0; /* fractional step */
double r; /* temptative rate */
double j = 1.0; /* index */
double dExp;
while( j < 1020.0 ) /* maximum anual rate */
{
HB_MATH_EXCEPTION hb_exc;
double dBase;
r = j * 0.000833333; /* j * ( 0.01 / 12.0) mensual's rate */
/* replace PAYMENT() function overhead */
hb_mathResetError( &hb_exc );
dBase = 1.0 + r;
dExp = pow( dBase, dTime );
if( hb_mathGetError( &hb_exc, "POW", dBase, dTime, dExp ) )
{
/* TODO: Check if this is a correct default correction value for pow() */
dExp = hb_exc.handled ? hb_exc.retval : 0.0;
}
dAux = dCapital * ( ( dExp * r ) / ( dExp - 1.0 ) );
if( dAux > dPayment )
{
j = j - dScale;
dScale = dScale * 0.10;
if( ( dAux - dPayment ) < dEpsilon )
break;
}
else
j = j + dScale;
} /* endwhile */
hb_retnd( j * 0.000833333 ); /* return as mensual's rate */
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_RATE, NULL, "RATE", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| finan.c | 538 |
ftoc.c |
Type | Function | Source | Line |
HB_FUNC | FTOC(void)
HB_FUNC( FTOC )
{
union
{
double value;
char string[sizeof( double )];
} xConvert;
xConvert.value = hb_parnd( 1 );
hb_retclen( xConvert.string, sizeof( double ) );
}
| ftoc.c | 93 |
HB_FUNC | CTOF(void)
HB_FUNC( CTOF )
{
union
{
double value;
char string[sizeof( double )];
} xConvert;
if( hb_parclen( 1 ) >= sizeof( double ) )
{
memcpy( xConvert.string, hb_parc( 1 ), sizeof( double ) );
hb_retnd( xConvert.value );
}
else
hb_retnd( 0.0 );
}
| ftoc.c | 145 |
justify.c |
Type | Function | Source | Line |
STATIC VOID | do_justify( int iSwitch )
static void do_justify( int iSwitch )
{
int iNoRet;
iNoRet = ct_getref() && ISBYREF( 1 );
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = hb_parclen( 1 );
char cJustChar;
char *pc, *pcRet;
size_t sJustOffset;
if( sStrLen == 0 )
{
if( iNoRet )
hb_ret();
else
hb_retc( NULL );
return;
}
if( hb_parclen( 2 ) > 0 )
cJustChar = *( hb_parc( 2 ) );
else if( ISNUM( 2 ) )
cJustChar = ( char ) ( hb_parnl( 2 ) % 256 );
else
cJustChar = 0x20;
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
switch ( iSwitch )
{
case DO_JUSTIFY_JUSTLEFT:
pc = pcString;
sJustOffset = 0;
while( ( *pc == cJustChar ) && ( pc < pcString + sStrLen ) )
{
sJustOffset++;
pc++;
}
hb_xmemcpy( pcRet, pcString + sJustOffset, sStrLen - sJustOffset );
for( pc = pcRet + sStrLen - sJustOffset; pc < pcRet + sStrLen; pc++ )
{
*pc = cJustChar;
}
break;
case DO_JUSTIFY_JUSTRIGHT:
pc = pcString + sStrLen - 1;
sJustOffset = 0;
while( ( *pc == cJustChar ) && ( pc >= pcString ) )
{
sJustOffset++;
pc--;
}
for( pc = pcRet; pc < pcRet + sJustOffset; pc++ )
{
*pc = cJustChar;
}
hb_xmemcpy( pcRet + sJustOffset, pcString, sStrLen - sJustOffset );
break;
}
if( ISBYREF( 1 ) )
hb_storclen( pcRet, sStrLen, 1 );
if( iNoRet )
{
hb_ret();
hb_xfree( pcRet );
}
else
hb_retclen_buffer( pcRet, sStrLen );
}
else /* ISCHAR( 1 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_JUSTIFY_JUSTLEFT ?
CT_ERROR_JUSTLEFT : CT_ERROR_JUSTRIGHT,
NULL, HB_ERR_FUNCNAME, 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_ret();
else
hb_retc( NULL );
}
}
| justify.c | 63 |
HB_FUNC | JUSTLEFT(void)
HB_FUNC( JUSTLEFT )
{
do_justify( DO_JUSTIFY_JUSTLEFT );
}
| justify.c | 194 |
HB_FUNC | JUSTRIGHT(void)
HB_FUNC( JUSTRIGHT )
{
do_justify( DO_JUSTIFY_JUSTRIGHT );
}
| justify.c | 228 |
keyset.c |
Type | Function | Source | Line |
STATIC VOID | SetGet( int iFlag )
static void SetGet( int iFlag )
{
int iState = 0, iNewState;
HB_GT_INFO gtInfo;
gtInfo.pNewVal = gtInfo.pResult = NULL;
hb_gtInfo( GTI_KBDSHIFTS, >Info );
if( gtInfo.pResult )
{
iState = hb_itemGetNI( gtInfo.pResult );
gtInfo.pNewVal = gtInfo.pResult;
gtInfo.pResult = NULL;
}
if( ISLOG( 1 ) )
{
iNewState = hb_parl( 1 ) ? ( iState | iFlag ) : ( iState & ~iFlag );
gtInfo.pNewVal = hb_itemPutNI( gtInfo.pNewVal, iNewState );
hb_gtInfo( GTI_KBDSHIFTS, >Info );
}
if( gtInfo.pNewVal )
hb_itemRelease( gtInfo.pNewVal );
if( gtInfo.pResult )
hb_itemRelease( gtInfo.pResult );
hb_retl( ( iState & iFlag ) != 0 );
}
| keyset.c | 59 |
HB_FUNC | KSETINS(void)
HB_FUNC( KSETINS )
{
SetGet( GTI_KBD_INSERT );
}
| keyset.c | 115 |
HB_FUNC | KSETCAPS(void)
HB_FUNC( KSETCAPS )
{
SetGet( GTI_KBD_CAPSLOCK );
}
| keyset.c | 146 |
HB_FUNC | KSETNUM(void)
HB_FUNC( KSETNUM )
{
SetGet( GTI_KBD_NUMLOCK );
}
| keyset.c | 177 |
HB_FUNC | KSETSCROLL(void)
HB_FUNC( KSETSCROLL )
{
SetGet( GTI_KBD_SCROLOCK );
}
| keyset.c | 208 |
like.c |
Type | Function | Source | Line |
HB_FUNC | LIKE(void)
HB_FUNC( LIKE )
{
char * szPattern = hb_parc( 1 ),
* szString = hb_parc( 2 );
hb_retl( szPattern && szString &&
hb_strMatchWildExact( szString, szPattern ) );
}
| like.c | 56 |
lton.c |
Type | Function | Source | Line |
HB_FUNC | LTON(void)
HB_FUNC( LTON )
{
hb_retni( ISLOG( 1 ) && hb_parl( 1 ) ? 1 : 0 );
}
| lton.c | 56 |
maxline.c |
Type | Function | Source | Line |
HB_FUNC | MAXLINE(void)
HB_FUNC( MAXLINE )
{
LONG lLength = 0;
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
char *pBuffer;
LONG lStrLen = hb_parclen( 1 );
while( lStrLen > 0 )
{
pBuffer = ( char * ) memchr( pcString, 13, lStrLen );
if( !pBuffer )
pBuffer = pcString + lStrLen;
if( pBuffer - pcString > lLength )
lLength = pBuffer - pcString;
pBuffer++;
if( *pBuffer == 10 )
pBuffer++;
lStrLen -= pBuffer - pcString;
pcString = pBuffer;
}
}
hb_retnl( lLength );
}
| maxline.c | 56 |
misc1.c |
Type | Function | Source | Line |
HB_FUNC | XTOC(void)
HB_FUNC( XTOC )
{
union
{
double value;
char string[sizeof( double )];
} xConvert;
if( ISCHAR( 1 ) )
hb_retc( hb_parc( 1 ) );
else if( ISDATE( 1 ) )
hb_retc( hb_pards( 1 ) );
else if( ISNUM( 1 ) )
{
xConvert.value = hb_parnd( 1 );
hb_retclen( xConvert.string, sizeof( double ) );
}
else if( ISLOG( 1 ) )
hb_retclen( hb_parl( 1 ) ? "T" : "F", 1 );
else
hb_retc( NULL );
}
| misc1.c | 103 |
misc2.c |
Type | Function | Source | Line |
HB_FUNC | COMPLEMENT(void)
HB_FUNC( COMPLEMENT )
{
PHB_ITEM pItem = hb_param( 1, HB_IT_ANY );
if( pItem )
{
if( HB_IS_STRING( pItem ) )
{
ULONG ulLen = hb_itemGetCLen( pItem ), ulPos;
if( ulLen > 0 )
{
char *szBuffer = ( char * ) hb_xgrab( ulLen + 1 ), *szSrc = hb_itemGetCPtr( pItem );
for( ulPos = 0; ulPos < ulLen; ulPos++ )
szBuffer[ulPos] = ~szSrc[ulPos];
hb_retclen_buffer( szBuffer, ulLen );
}
else
hb_retc( NULL );
}
else if( HB_IS_DATE( pItem ) )
hb_retdl( 4537847 - hb_itemGetDL( pItem ) );
else if( HB_IS_NUMINT( pItem ) )
hb_retnint( -hb_itemGetNInt( pItem ) );
else if( HB_IS_NUMERIC( pItem ) )
{
int iWidth, iDec;
double dValue;
dValue = hb_itemGetND( pItem );
hb_itemGetNLen( pItem, &iWidth, &iDec );
hb_retndlen( -dValue, iWidth, iDec );
}
else if( HB_IS_LOGICAL( pItem ) )
hb_retl( !hb_itemGetL( pItem ) );
else
hb_ret();
}
else
hb_ret();
}
| misc2.c | 56 |
HB_FUNC | NUL(void)
HB_FUNC( NUL )
{
hb_retc( NULL );
}
| misc2.c | 100 |
misc3.c |
Type | Function | Source | Line |
HB_FUNC | KBDSTAT(void)
HB_FUNC( KBDSTAT )
{
int iRet = 0;
HB_GT_INFO gtInfo;
gtInfo.pNewVal = NULL;
gtInfo.pResult = NULL;
hb_gtInfo( GTI_KBDSHIFTS, >Info );
if( gtInfo.pResult )
{
int iState = hb_itemGetNI( gtInfo.pResult );
hb_itemRelease( gtInfo.pResult );
if( iState & GTI_KBD_SHIFT )
iRet |= 0x01;
if( iState & GTI_KBD_CTRL )
iRet |= 0x04;
if( iState & GTI_KBD_ALT )
iRet |= 0x08;
if( iState & GTI_KBD_SCROLOCK )
iRet |= 0x10;
if( iState & GTI_KBD_NUMLOCK )
iRet |= 0x20;
if( iState & GTI_KBD_CAPSLOCK )
iRet |= 0x40;
if( iState & GTI_KBD_INSERT )
iRet |= 0x80;
}
hb_retni( iRet );
}
| misc3.c | 57 |
num1.c |
Type | Function | Source | Line |
HB_FUNC | CELSIUS(void)
HB_FUNC( CELSIUS )
{
if( ISNUM( 1 ) )
{
double dInput = hb_parnd( 1 );
double dResult;
dResult = ( 5.0 / 9.0 ) * ( dInput - 32.0 );
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CELSIUS, NULL, "CELSIUS", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| num1.c | 105 |
HB_FUNC | FAHRENHEIT(void)
HB_FUNC( FAHRENHEIT )
{
if( ISNUM( 1 ) )
{
double dInput = hb_parnd( 1 );
double dResult;
dResult = ( ( 9.0 / 5.0 ) * dInput ) + 32.0;
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_FAHRENHEIT, NULL, "FAHRENHEIT", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| num1.c | 172 |
HB_FUNC | INFINITY(void)
HB_FUNC( INFINITY )
{
if( ISLOG( 1 ) && hb_parl( 1 ) )
hb_retnd( DBL_MAX );
else
hb_retnd( 93786976294838206460.00 );
}
| num1.c | 237 |
numat.c |
Type | Function | Source | Line |
HB_FUNC | NUMAT(void)
HB_FUNC( NUMAT )
{
if( ( ISCHAR( 1 ) ) && ( ISCHAR( 2 ) ) )
{
char *pcStringToMatch = ( char * ) hb_parc( 1 );
size_t sStrToMatchLen = ( size_t ) hb_parclen( 1 );
char *pcString = ( char * ) hb_parc( 2 );
size_t sStrLen = ( size_t ) hb_parclen( 2 );
int iMultiPass = ct_getatmupa();
int iAtLike = ct_getatlike();
char cAtLike = ct_getatlikechar();
size_t sIgnore, sMatchStrLen, sSubStrLen;
ULONG ulCounter;
char *pc, *pcSubStr;
/* eventually ignore some characters */
if( ISNUM( 3 ) )
sIgnore = ( size_t ) hb_parnl( 3 );
else
sIgnore = 0;
if( sIgnore >= sStrLen )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_NUMAT, NULL,
"NUMAT", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( 0 );
return;
}
else
{
pcString += sIgnore;
sStrLen -= sIgnore;
}
ulCounter = 0;
pcSubStr = pcString;
sSubStrLen = sStrLen;
do
{
switch ( iAtLike )
{
case CT_SETATLIKE_EXACT:
pc = ct_at_exact_forward( pcSubStr, sSubStrLen, pcStringToMatch,
sStrToMatchLen, &sMatchStrLen );
break;
case CT_SETATLIKE_WILDCARD:
pc = ct_at_wildcard_forward( pcSubStr, sSubStrLen,
pcStringToMatch, sStrToMatchLen,
cAtLike, &sMatchStrLen );
break;
default:
pc = NULL;
}
ulCounter++;
if( iMultiPass )
pcSubStr = pc + 1;
else
pcSubStr = pc + sMatchStrLen;
sSubStrLen = sStrLen - ( pcSubStr - pcString );
}
while( pc != NULL );
hb_retnl( ulCounter - 1 );
}
else /* ( ISCHAR( 1 ) && ISCHAR( 2 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_NUMAT, NULL, "NUMAT", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| numat.c | 86 |
numcount.c |
Type | Function | Source | Line |
HB_FUNC | NUMCOUNT(void)
HB_FUNC( NUMCOUNT )
{
BOOL bMode = ISLOG( 2 ) && hb_parl( 2 );
if( ISNUM( 1 ) )
{
if( bMode )
s_lCounter = hb_parnl( 1 );
else
s_lCounter += hb_parnl( 1 );
}
hb_retnl( s_lCounter );
}
| numcount.c | 58 |
numline.c |
Type | Function | Source | Line |
HB_FUNC | NUMLINE(void)
HB_FUNC( NUMLINE )
{
LONG lLines = 0;
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
char *pBuffer;
LONG lStrLen = hb_parclen( 1 );
LONG lLength = ISNUM( 2 ) ? hb_parnl( 2 ) : 80;
while( lStrLen > 0 )
{
pBuffer = ( char * ) memchr( pcString, 13, lStrLen );
if( !pBuffer )
{
pBuffer = pcString + lStrLen;
}
if( ( pBuffer - pcString ) > lLength )
{
pBuffer = pcString + lLength;
}
else
{
pBuffer++;
if( *pBuffer == 10 )
pBuffer++;
}
lStrLen -= pBuffer - pcString;
pcString = pBuffer;
lLines++;
}
}
hb_retnl( lLines );
}
| numline.c | 56 |
pack.c |
Type | Function | Source | Line |
HB_FUNC | CHARPACK(void)
HB_FUNC( CHARPACK )
{
unsigned len = hb_parclen( 1 );
unsigned char *in = ( unsigned char * ) hb_parcx( 1 );
if( hb_parni( 2 ) == 0 )
{
unsigned char *out = ( unsigned char * ) hb_xgrab( len * 3 + 2 );
unsigned n_in = 0, n_out = 0;
out[n_out++] = 158;
out[n_out++] = 158;
while( n_in < len )
{
int n_count = 1, n_max = HB_MIN( 255, len - n_in );
unsigned char c = in[n_in];
while( n_count < n_max && in[n_in + n_count] == c )
n_count++;
out[n_out++] = 0;
out[n_out++] = n_count;
out[n_out++] = c;
n_in += n_count;
}
if( n_out < len )
hb_retclen( ( char * ) out, n_out );
hb_xfree( out );
if( n_out < len )
return;
}
hb_retclen( ( char * ) in, len );
}
| pack.c | 57 |
STATIC UNSIGNED CHAR | buf_append( unsigned char *buf, unsigned *buf_size, unsigned count, unsigned char c, unsigned *buf_len )
static unsigned char *buf_append( unsigned char *buf, unsigned *buf_size, unsigned count,
unsigned char c, unsigned *buf_len )
{
if( *buf_len + count > *buf_size )
{
*buf_size = HB_MAX( *buf_len + count, *buf_size + 32768 );
buf = ( unsigned char * ) hb_xrealloc( buf, *buf_size );
}
memset( buf + *buf_len, c, count );
*buf_len += count;
return buf;
}
| pack.c | 92 |
HB_FUNC | CHARUNPACK(void)
HB_FUNC( CHARUNPACK )
{
unsigned buf_size = 32768;
unsigned len = hb_parclen( 1 );
unsigned out_len = 0;
unsigned char *in = ( unsigned char * ) hb_parcx( 1 );
unsigned char *out;
unsigned i;
if( hb_parni( 2 ) == 0 )
{
if( !( in[0] == 158 && in[1] == 158 ) )
{
hb_retclen( ( char * ) in, len );
return;
}
out = ( unsigned char * ) hb_xgrab( buf_size );
for( i = 2; i <= len - 3; i += 3 )
{
if( in[i] != 0 )
{
hb_xfree( out );
hb_retclen( ( char * ) in, len );
return;
}
out = buf_append( out, &buf_size, in[i + 1], in[i + 2], &out_len );
}
hb_retclen( ( char * ) out, out_len );
hb_xfree( out );
return;
}
hb_retclen( ( char * ) in, len );
}
| pack.c | 106 |
pos1.c |
Type | Function | Source | Line |
STATIC VOID | do_pos1( int iSwitch )
static void do_pos1( int iSwitch )
{
if( ISCHAR( 1 ) && /* all functions need string as 1st param */
( iSwitch != DO_POS1_POSRANGE || /* that's the only condition for all funcs _except_ POSRANGE */
( iSwitch == DO_POS1_POSRANGE && /* In addition, POSRANGE needs .. */
ISCHAR( 2 ) && /* .. string as 2nd .. */
ISCHAR( 3 ) ) ) ) /* .. and 3rd param */
{
unsigned char *pcString;
size_t sStrLen;
unsigned char *puc, ucChar1 = ' ', ucChar2 = ' ';
int iMode;
size_t sIgnore;
int iParamShift = 0;
if( iSwitch == DO_POS1_POSRANGE )
{
if( hb_parclen( 1 ) == 0 )
{
hb_retni( 0 );
return;
}
else
{
ucChar1 = *( hb_parc( 1 ) );
}
if( hb_parclen( 2 ) == 0 )
{
hb_retni( 0 );
return;
}
else
{
ucChar2 = *( hb_parc( 2 ) );
}
iParamShift += 2;
}
pcString = ( unsigned char * ) hb_parc( iParamShift + 1 );
sStrLen = ( size_t ) hb_parclen( iParamShift + 1 );
if( ISLOG( iParamShift + 2 ) )
iMode = hb_parl( iParamShift + 2 );
else
iMode = 0;
if( ISNUM( iParamShift + 3 ) )
sIgnore = ( size_t ) hb_parnl( iParamShift + 3 );
else
sIgnore = 0;
for( puc = pcString + sIgnore; puc < pcString + sStrLen; puc++ )
{
int iDoRet = 0;
switch ( iSwitch )
{
case DO_POS1_POSALPHA:
iDoRet = ISALPHA( *puc );
break;
case DO_POS1_POSLOWER:
iDoRet = ISLOWER( *puc );
break;
case DO_POS1_POSRANGE:
iDoRet = ( ( ucChar1 <= *puc ) && ( ucChar2 >= *puc ) );
break;
case DO_POS1_POSUPPER:
iDoRet = ISUPPER( *puc );
break;
}
if( ( iMode && !iDoRet ) || ( !iMode && iDoRet ) )
{
hb_retnl( puc - pcString + 1 );
return;
}
}
hb_retni( 0 );
}
else /* ISCHAR (1) etc. */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode(), iError = 0;
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
switch ( iSwitch )
{
case DO_POS1_POSALPHA:
iError = CT_ERROR_POSALPHA;
break;
case DO_POS1_POSLOWER:
iError = CT_ERROR_POSLOWER;
break;
case DO_POS1_POSRANGE:
iError = CT_ERROR_POSRANGE;
break;
case DO_POS1_POSUPPER:
iError = CT_ERROR_POSUPPER;
break;
}
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG, iError,
NULL, HB_ERR_FUNCNAME, 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| pos1.c | 79 |
HB_FUNC | POSALPHA(void)
HB_FUNC( POSALPHA )
{
do_pos1( DO_POS1_POSALPHA );
}
| pos1.c | 231 |
HB_FUNC | POSLOWER(void)
HB_FUNC( POSLOWER )
{
do_pos1( DO_POS1_POSLOWER );
}
| pos1.c | 265 |
HB_FUNC | POSRANGE(void)
HB_FUNC( POSRANGE )
{
do_pos1( DO_POS1_POSRANGE );
}
| pos1.c | 300 |
HB_FUNC | POSUPPER(void)
HB_FUNC( POSUPPER )
{
do_pos1( DO_POS1_POSUPPER );
}
| pos1.c | 334 |
pos2.c |
Type | Function | Source | Line |
HB_FUNC | POSCHAR(void)
HB_FUNC( POSCHAR )
{
int iNoRet;
iNoRet = ct_getref() && ISBYREF( 1 );
if( hb_parclen( 1 ) > 0 )
{
if( ( hb_parclen( 2 ) > 0 ) || ISNUM( 2 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = hb_parclen( 1 );
char *pcRet;
char cReplace;
size_t sPosition;
if( ISCHAR( 2 ) )
cReplace = *( hb_parc( 2 ) );
else
cReplace = ( char ) ( hb_parnl( 2 ) % 256 );
if( ISNUM( 3 ) )
{
sPosition = hb_parnl( 3 );
if( sPosition == 0 )
sPosition = sStrLen;
}
else
sPosition = sStrLen;
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
hb_xmemcpy( pcRet, pcString, sStrLen );
*( pcRet + sPosition - 1 ) = cReplace;
if( ISBYREF( 1 ) )
hb_storclen( pcRet, sStrLen, 1 );
if( iNoRet )
{
hb_ret();
hb_xfree( pcRet );
}
else
hb_retclen_buffer( pcRet, sStrLen );
}
else /* ( hb_parclen( 2 ) > 0 ) || ISNUM( 2 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_POSCHAR, NULL, "POSCHAR", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_ret();
else
hb_retclen( hb_parc( 1 ), hb_parclen( 1 ) );
}
}
else /* hb_parclen( 1 ) > 0 */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_POSCHAR, NULL, "POSCHAR", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_ret();
else
hb_retc( NULL );
}
}
| pos2.c | 87 |
HB_FUNC | POSDEL(void)
HB_FUNC( POSDEL )
{
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = hb_parclen( 1 );
size_t sStartPos, sDelLen;
char *pcRet;
if( ISNUM( 3 ) )
sDelLen = hb_parnl( 3 );
else
sDelLen = 1; /* set new standard behavior */
if( ISNUM( 2 ) )
{
sStartPos = hb_parnl( 2 );
if( sStartPos == 0 || sStartPos > sStrLen - sDelLen + 1 )
sStartPos = sStrLen - sDelLen + 1;
}
else
sStartPos = sStrLen - sDelLen + 1;
if( sStrLen <= sDelLen )
{
hb_retc( NULL );
return;
}
pcRet = ( char * ) hb_xgrab( sStrLen - sDelLen + 1 );
/* copy first part */
if( sStartPos > 1 )
{
hb_xmemcpy( pcRet, pcString, sStartPos - 1 );
}
/* copy second part */
if( sStrLen > ( sStartPos - 1 + sDelLen ) )
{
hb_xmemcpy( pcRet + sStartPos - 1, pcString + sStartPos - 1 + sDelLen,
sStrLen - ( sStartPos - 1 + sDelLen ) );
}
hb_retclen_buffer( pcRet, sStrLen - sDelLen );
}
else /* ISCHAR( 1 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_POSDEL, NULL, "POSDEL", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| pos2.c | 202 |
HB_FUNC | POSINS(void)
HB_FUNC( POSINS )
{
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = hb_parclen( 1 );
char *pcInsert;
size_t sInsLen;
if( ( sInsLen = hb_parclen( 2 ) ) > 0 )
{
size_t sStartPos;
char *pcRet;
pcInsert = hb_parc( 2 );
if( ISNUM( 3 ) )
{
sStartPos = hb_parnl( 3 );
if( sStartPos == 0 )
sStartPos = sStrLen;
}
else
sStartPos = sStrLen;
/* check for false sStartPos */
if( sStartPos > sStrLen + 1 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSINS,
NULL, "POSINS", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
hb_retclen( pcString, sStrLen );
return;
}
pcRet = ( char * ) hb_xgrab( sStrLen + sInsLen + 1 );
/* copy first part */
if( sStartPos > 1 )
hb_xmemcpy( pcRet, pcString, sStartPos - 1 );
/* insert string */
hb_xmemcpy( pcRet + sStartPos - 1, pcInsert, sInsLen );
/* copy second part */
if( sStrLen > ( sStartPos - 1 ) )
{
hb_xmemcpy( pcRet + sStartPos - 1 + sInsLen, pcString + sStartPos - 1,
sStrLen - ( sStartPos - 1 ) );
}
hb_retclen_buffer( pcRet, sStrLen + sInsLen );
}
else /* hb_parclen( 2 ) > 0 */
hb_retclen( pcString, sStrLen );
}
else /* ISCHAR( 1 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_POSINS, NULL, "POSINS", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| pos2.c | 296 |
HB_FUNC | POSREPL(void)
HB_FUNC( POSREPL )
{
int iNoRet;
iNoRet = ct_getref() && ISBYREF( 1 );
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = hb_parclen( 1 );
char *pcReplace;
size_t sReplLen;
if( ( sReplLen = hb_parclen( 2 ) ) > 0 )
{
size_t sStartPos;
char *pcRet;
size_t sRetLen;
pcReplace = hb_parc( 2 );
if( ISNUM( 3 ) )
{
sStartPos = hb_parnl( 3 );
if( sStartPos == 0 )
{
if( sReplLen > sStrLen )
sStartPos = 1;
else
sStartPos = sStrLen - sReplLen + 1;
}
}
else
{
if( sReplLen > sStrLen )
sStartPos = 1;
else
sStartPos = sStrLen - sReplLen + 1;
}
/* check for false sStartPos */
if( sStartPos > sStrLen + 1 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSREPL,
NULL, "POSREPL", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
if( iNoRet )
hb_ret();
else
hb_retclen( pcString, sStrLen );
return;
}
if( sStrLen > ( sStartPos + sReplLen - 1 ) )
sRetLen = sStrLen;
else
sRetLen = sStartPos + sReplLen - 1;
pcRet = ( char * ) hb_xgrab( sRetLen + 1 );
/* copy first part */
if( sStartPos > 1 )
hb_xmemcpy( pcRet, pcString, sStartPos - 1 );
/* insert replacement string */
hb_xmemcpy( pcRet + sStartPos - 1, pcReplace, sReplLen );
/* copy second part */
if( sStrLen > ( sStartPos - 1 + sReplLen ) )
hb_xmemcpy( pcRet + sStartPos - 1 + sReplLen, pcString + sStartPos - 1 + sReplLen,
sStrLen - ( sStartPos - 1 + sReplLen ) );
if( ISBYREF( 1 ) )
{
hb_storclen( pcRet, sRetLen, 1 );
}
if( iNoRet )
{
hb_xfree( pcRet );
hb_ret();
}
else
hb_retclen_buffer( pcRet, sRetLen );
}
else /* hb_parclen( 2 ) > 0 */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_POSREPL, NULL, "POSREPL", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_ret();
else
hb_retclen( pcString, sStrLen );
}
}
else /* ISCHAR( 1 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_POSREPL, NULL, "POSREPL", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_ret();
else
hb_retc( NULL );
}
}
| pos2.c | 405 |
posdiff.c |
Type | Function | Source | Line |
HB_FUNC | POSDIFF(void)
HB_FUNC( POSDIFF )
{
if( ISCHAR( 1 ) && ISCHAR( 2 ) )
{
char *pcString1 = hb_parc( 1 );
size_t sStrLen1 = hb_parclen( 1 );
char *pcString2 = hb_parc( 2 );
size_t sStrLen2 = hb_parclen( 2 );
char *pc1, *pc2;
size_t sIgnore;
if( ISNUM( 3 ) )
sIgnore = hb_parnl( 3 );
else
sIgnore = 0;
if( ( sIgnore > sStrLen1 ) || ( sIgnore > sStrLen2 ) )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSDIFF, NULL,
"POSDIFF", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( 0 );
return;
}
pc1 = pcString1 + sIgnore;
pc2 = pcString2 + sIgnore;
while( ( pc1 < pcString1 + sStrLen1 ) && ( pc2 < pcString2 + sStrLen2 ) )
{
if( *pc1 != *pc2 )
{
hb_retnl( ( pc1 - pcString1 ) + 1 );
return;
}
pc1++;
pc2++;
}
if( sStrLen1 != sStrLen2 )
hb_retnl( ( sStrLen1 < sStrLen2 ? sStrLen1 : sStrLen2 ) + 1 );
else
hb_retni( 0 );
}
else /* ( ISCHAR( 1 ) && ISCHAR( 2 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_POSDIFF, NULL, "POSDIFF", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( ISCHAR( 1 ) || ISCHAR( 2 ) )
hb_retnl( 1 );
else
hb_retni( 0 );
}
}
| posdiff.c | 87 |
HB_FUNC | POSEQUAL(void)
HB_FUNC( POSEQUAL )
{
if( ISCHAR( 1 ) && ISCHAR( 2 ) )
{
char *pcString1 = hb_parc( 1 );
size_t sStrLen1 = hb_parclen( 1 );
char *pcString2 = hb_parc( 2 );
size_t sStrLen2 = hb_parclen( 2 );
char *pc1, *pc2;
size_t sIgnore, sCompare, sCompareCnt, sRet = 0;
if( ISNUM( 4 ) )
sIgnore = hb_parnl( 4 );
else
sIgnore = 0;
if( ISNUM( 3 ) )
sCompare = hb_parnl( 3 );
else
sCompare = ( sStrLen1 < sStrLen2 ? sStrLen1 : sStrLen2 ) - sIgnore;
if( ( sCompare == 0 ) || ( sIgnore > sStrLen1 ) || ( sIgnore > sStrLen2 ) )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSEQUAL, NULL,
"POSEQUAL", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( 0 );
return;
}
if( ( sStrLen1 < ( sCompare + sIgnore ) ) || ( sStrLen2 < ( sCompare + sIgnore ) ) )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_POSEQUAL, NULL,
"POSEQUAL", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( 0 );
return;
}
pc1 = pcString1 + sIgnore;
pc2 = pcString2 + sIgnore;
sCompareCnt = 0;
while( pc1 < pcString1 + sStrLen1 )
{
if( *pc1 == *pc2 )
{
/* save possible return value */
if( sCompareCnt == 0 )
sRet = pc1 - pcString1 + 1;
sCompareCnt++;
if( sCompareCnt == sCompare )
{
hb_retnl( sRet );
return;
}
}
else
{
/* reset compare counter */
sCompareCnt = 0;
}
pc1++;
pc2++;
}
hb_retni( 0 );
}
else /* ( ISCHAR( 1 ) && ISCHAR( 2 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_POSEQUAL, NULL, "POSEQUAL", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| posdiff.c | 185 |
print.c |
Type | Function | Source | Line |
HB_FUNC | PRINTSTAT(void)
HB_FUNC( PRINTSTAT )
{
USHORT uiPort = ISNUM( 1 ) ? hb_parni( 1 ) : 1;
int Status = 0;
#if defined(HB_OS_DOS)
/* NOTE: DOS specific solution, using BIOS interrupt */
union REGS regs;
regs.h.ah = 2;
regs.HB_XREGS.dx = uiPort - 1;
HB_DOS_INT86( 0x17, ®s, ®s );
Status = regs.h.ah;
#else
HB_SYMBOL_UNUSED( uiPort );
#endif
hb_retni( Status );
}
| print.c | 92 |
HB_FUNC | PRINTREADY(void)
HB_FUNC( PRINTREADY )
{
USHORT uiPort = ISNUM( 1 ) ? hb_parni( 1 ) : 1;
int Status = 0;
#if defined(HB_OS_DOS)
/* NOTE: DOS specific solution, using BIOS interrupt */
union REGS regs;
regs.h.ah = 2;
regs.HB_XREGS.dx = uiPort - 1;
HB_DOS_INT86( 0x17, ®s, ®s );
Status = regs.h.ah;
#else
HB_SYMBOL_UNUSED( uiPort );
#endif
hb_retl( ( Status == 0x90 ) );
}
| print.c | 143 |
HB_FUNC | PRINTSEND(void)
HB_FUNC( PRINTSEND )
{
#ifdef __DJGPP__
__dpmi_regs r;
r.x.dx = hb_parni( 2 ) - 1;
if( ISNUM( 1 ) )
{
r.h.al = hb_parni( 1 );
__dpmi_int( 0x17, &r );
if( r.h.ah & 1 )
hb_retni( 1 );
else
hb_retni( 0 );
}
else if( ISCHAR( 1 ) )
{
char *string = hb_parcx( 1 );
int i, len = hb_parclen( 1 );
r.h.ah = 0;
for( i = 0; i < len && !( r.h.ah & 1 ); i++ )
{
r.h.al = string[i];
__dpmi_int( 0x17, &r );
}
if( r.h.ah & 1 )
hb_retni( len - ( i - 1 ) );
else
hb_retni( 0 );
}
#endif
}
| print.c | 169 |
range.c |
Type | Function | Source | Line |
HB_FUNC | RANGEREM(void)
HB_FUNC( RANGEREM )
{
if( ( hb_parclen( 1 ) > 0 || ISNUM( 1 ) ) &&
( hb_parclen( 2 ) > 0 || ISNUM( 2 ) ) && ISCHAR( 3 ) )
{
char *pcString = ( char * ) hb_parc( 3 );
size_t sStrLen = ( size_t ) hb_parclen( 3 );
char *pcRet;
unsigned char *pc;
unsigned char ucChar1, ucChar2;
size_t sRetIndex;
int iMode, iBool;
if( ISCHAR( 1 ) )
ucChar1 = *( ( unsigned char * ) hb_parc( 1 ) );
else
ucChar1 = ( unsigned char ) ( hb_parni( 1 ) % 256 );
if( ISCHAR( 2 ) )
ucChar2 = *( ( unsigned char * ) hb_parc( 2 ) );
else
ucChar2 = ( unsigned char ) ( hb_parni( 2 ) % 256 );
iMode = ( ucChar2 < ucChar1 );
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
sRetIndex = 0;
for( pc = ( unsigned char * ) pcString; pc < ( unsigned char * ) pcString + sStrLen; pc++ )
{
iBool = ( ( *pc ) >= ucChar1 );
if( iMode )
iBool |= ( ( *pc ) <= ucChar2 );
else
iBool &= ( ( *pc ) <= ucChar2 );
if( !iBool )
{
*( pcRet + sRetIndex ) = *pc;
sRetIndex++;
}
}
hb_retclen( pcRet, sRetIndex );
hb_xfree( pcRet );
}
else /* ( hb_parclen( 1 ) > 0 || ISNUM( 1 ) ) &&
( hb_parclen( 2 ) > 0 || ISNUM( 2 ) ) && ISCHAR( 3 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_RANGEREM, NULL, "RANGEREM", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( ISCHAR( 3 ) )
hb_retclen( hb_parc( 3 ), hb_parclen( 3 ) );
else
hb_retc( NULL );
}
}
| range.c | 94 |
HB_FUNC | RANGEREPL(void)
HB_FUNC( RANGEREPL )
{
int iNoRef = ct_getref() && ISBYREF( 3 );
if( ( hb_parclen( 1 ) > 0 || ISNUM( 1 ) ) &&
( hb_parclen( 2 ) > 0 || ISNUM( 2 ) ) &&
ISCHAR( 3 ) && ( hb_parclen( 4 ) > 0 || ISNUM( 4 ) ) )
{
char *pcString = ( char * ) hb_parc( 3 );
size_t sStrLen = ( size_t ) hb_parclen( 3 );
char *pcRet;
unsigned char *pc;
unsigned char ucChar1, ucChar2, ucReplace;
size_t sRetIndex;
int iMode, iBool;
if( ISCHAR( 1 ) )
ucChar1 = *( ( unsigned char * ) hb_parc( 1 ) );
else
ucChar1 = ( unsigned char ) ( hb_parni( 1 ) % 256 );
if( ISCHAR( 2 ) )
ucChar2 = *( ( unsigned char * ) hb_parc( 2 ) );
else
ucChar2 = ( unsigned char ) ( hb_parni( 2 ) % 256 );
if( ISCHAR( 4 ) )
ucReplace = *( ( unsigned char * ) hb_parc( 4 ) );
else
ucReplace = ( unsigned char ) ( hb_parni( 4 ) % 256 );
iMode = ( ucChar2 < ucChar1 );
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
sRetIndex = 0;
for( pc = ( unsigned char * ) pcString; pc < ( unsigned char * ) pcString + sStrLen; pc++ )
{
iBool = ( ( *pc ) >= ucChar1 );
if( iMode )
iBool |= ( ( *pc ) <= ucChar2 );
else
iBool &= ( ( *pc ) <= ucChar2 );
if( iBool )
{
*( pcRet + sRetIndex ) = ucReplace;
sRetIndex++;
}
else
{
*( pcRet + sRetIndex ) = *pc;
sRetIndex++;
}
}
if( ISBYREF( 3 ) )
hb_storclen( pcRet, sStrLen, 3 );
if( iNoRef )
/* Contrary to the official documentation, RANGREPL() returns NIL instead of .F.
* in this situation. If the string is not passed by reference, it returns the
* string regardless of iNoRef. */
hb_ret();
else
hb_retclen( pcRet, sStrLen );
hb_xfree( pcRet );
}
else /* ( hb_parclen( 1 ) > 0 || ISNUM( 1 ) ) &&
( hb_parclen( 2 ) > 0 || ISNUM( 2 ) ) &&
ISCHAR( 3 ) && ( hb_parclen( 4 ) > 0 || ISNUM( 4 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_RANGEREPL, NULL, "RANGEREPL", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRef )
hb_ret();
else if( ISCHAR( 3 ) )
hb_retclen( hb_parc( 3 ), hb_parclen( 3 ) );
else
hb_retc( NULL );
}
}
| range.c | 198 |
relation.c |
Type | Function | Source | Line |
HB_FUNC | CHARRELA(void)
HB_FUNC( CHARRELA )
{
if( ISCHAR( 1 ) && ISCHAR( 2 ) && ISCHAR( 3 ) && ISCHAR( 4 ) )
{
char *pcStringToMatch1 = hb_parc( 1 );
size_t sStrToMatchLen1 = hb_parclen( 1 );
char *pcString1 = hb_parc( 2 );
size_t sStrLen1 = hb_parclen( 2 );
char *pcStringToMatch2 = hb_parc( 3 );
size_t sStrToMatchLen2 = hb_parclen( 3 );
char *pcString2 = hb_parc( 4 );
size_t sStrLen2 = hb_parclen( 4 );
char *pc1, *pc2;
size_t sOffset1, sOffset2;
size_t sMatchStrLen;
/* check for empty strings */
if( ( sStrToMatchLen1 == 0 ) || ( sStrToMatchLen2 == 0 ) )
{
hb_retni( 0 );
return;
}
sOffset1 = 0;
sOffset2 = 0;
/* NOTE: this algorithm is not the best since the search that gave
the larger relative position in the step before is repeated;
try a search algorithm alternating between both strings */
while( sOffset1 < sStrLen1 && sOffset2 < sStrLen2 )
{
pc1 = ct_at_exact_forward( pcStringToMatch1, sStrToMatchLen1,
pcString1 + sOffset1, sStrLen1 - sOffset1, &sMatchStrLen );
pc2 = ct_at_exact_forward( pcStringToMatch2, sStrToMatchLen2,
pcString2 + sOffset2, sStrLen2 - sOffset2, &sMatchStrLen );
if( pc1 != NULL && pc2 != NULL )
{
if( pc1 - pcString1 == pc2 - pcString2 )
{
/* correlation found */
hb_retnl( ( pc1 - pcString1 ) + 1 );
return;
}
else
{
if( pc1 - pcString1 > pc2 - pcString2 )
sOffset1 = sOffset2 = pc1 - pcString1;
else
sOffset1 = sOffset2 = pc2 - pcString2;
}
}
else
{
sOffset1 = sOffset2 = sStrLen1 < sStrLen2 ? sStrLen1 : sStrLen2;
}
}
hb_retni( 0 );
}
else /* ISCHAR( 1 ) && ISCHAR( 2 ) && ISCHAR( 3 ) && ISCHAR( 4 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CHARRELA, NULL, "CHARRELA", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| relation.c | 88 |
HB_FUNC | CHARRELREP(void)
HB_FUNC( CHARRELREP )
{
int iNoRet;
iNoRet = ct_getref() && ISBYREF( 4 );
if( ISCHAR( 1 ) && ISCHAR( 2 ) && ISCHAR( 3 ) &&
ISCHAR( 4 ) && ISCHAR( 5 ) )
{
char *pcStringToMatch1 = hb_parc( 1 );
size_t sStrToMatchLen1 = hb_parclen( 1 );
char *pcString1 = hb_parc( 2 );
size_t sStrLen1 = hb_parclen( 2 );
char *pcStringToMatch2 = hb_parc( 3 );
size_t sStrToMatchLen2 = hb_parclen( 3 );
char *pcString2 = hb_parc( 4 );
size_t sStrLen2 = hb_parclen( 4 );
char *pcReplace = hb_parc( 5 );
size_t sReplaceLen = hb_parclen( 5 );
char *pcRet;
char *pc1, *pc2;
size_t sOffset1, sOffset2;
size_t sMatchStrLen;
/* check for empty strings */
if( sStrToMatchLen1 == 0 ||
sStrToMatchLen2 == 0 || sReplaceLen == 0 || sStrLen2 == 0 )
{
if( iNoRet )
hb_ret();
else
hb_retclen( pcString2, sStrLen2 );
return;
}
pcRet = ( char * ) hb_xgrab( sStrLen2 + 1 );
hb_xmemcpy( pcRet, pcString2, sStrLen2 );
sOffset1 = 0;
sOffset2 = 0;
/* NOTE: this algorithm is not the best since the search that gave
the larger relative position in the step before is repeated;
try a search algorithm alternating between both strings */
while( ( sOffset1 < sStrLen1 ) && ( sOffset2 < sStrLen2 ) )
{
pc1 = ct_at_exact_forward( pcStringToMatch1, sStrToMatchLen1,
pcString1 + sOffset1, sStrLen1 - sOffset1,
&sMatchStrLen );
pc2 = ct_at_exact_forward( pcStringToMatch2, sStrToMatchLen2,
pcString2 + sOffset2, sStrLen2 - sOffset2,
&sMatchStrLen );
if( pc1 != NULL && pc2 != NULL )
{
if( pc1 - pcString1 == pc2 - pcString2 )
{
/* correlation found -> start replacement */
size_t sCurr;
for( sCurr = 1; sCurr <= sStrToMatchLen1; sCurr++ )
{
/* check if pcString2 is long enough */
if( ( pc2 - pcString2 ) + sCurr >= sStrLen2 )
{
size_t sStr2Offset, sReplOffset;
sStr2Offset = sStrToMatchLen2 < sCurr ? sStrToMatchLen2 : sCurr;
sReplOffset = sReplaceLen < sCurr ? sReplaceLen : sCurr;
/* do the characters in pcString2 and pcStrToMatch2 match ? */
if( *( pc2 + sCurr - 1 ) ==
*( pcStringToMatch2 + sStr2Offset - 1 ) )
{
*( pcRet + ( pc2 - pcString2 ) + sCurr - 1 ) =
*( pcReplace + sReplOffset - 1 );
}
}
}
sOffset1 = sOffset2 = ( pc1 - pcString1 ) + 1;
}
else
{
if( pc1 - pcString1 > pc2 - pcString2 )
sOffset1 = sOffset2 = pc1 - pcString1;
else
sOffset1 = sOffset2 = pc2 - pcString2;
}
}
else
{
sOffset1 = sOffset2 = sStrLen1 < sStrLen2 ? sStrLen1 : sStrLen2;
}
}
if( ISBYREF( 4 ) )
{
hb_storclen( pcRet, sStrLen2, 4 );
}
if( iNoRet )
{
hb_xfree( pcRet );
hb_ret();
}
else
{
hb_retclen_buffer( pcRet, sStrLen2 );
}
}
else /* ISCHAR( 1 ) && ISCHAR( 2 ) && ISCHAR( 3 ) &&
ISCHAR( 4 ) && ISCHAR( 5 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_CHARRELREP, NULL, "CHARRELREP", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_ret();
else
hb_retc( NULL );
}
}
| relation.c | 198 |
remove.c |
Type | Function | Source | Line |
STATIC VOID | do_remove( int iSwitch )
static void do_remove( int iSwitch )
{
/* param check */
if( ISCHAR( 1 ) )
{
char *pcString = ( char * ) hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcRet, *pc;
size_t sRetLen;
char cSearch;
if( hb_parclen( 2 ) > 0 )
cSearch = *( hb_parc( 2 ) );
else if( ISNUM( 2 ) )
cSearch = ( char ) ( hb_parnl( 2 ) % 256 );
else
cSearch = 0x20;
sRetLen = sStrLen;
pcRet = pcString;
if( iSwitch != DO_REMOVE_REMRIGHT )
{
while( ( *pcRet == cSearch ) && ( pcRet < pcString + sStrLen ) )
{
pcRet++;
sRetLen--;
}
}
if( iSwitch != DO_REMOVE_REMLEFT )
{
pc = pcString + sStrLen - 1;
while( ( *pc == cSearch ) && ( pc >= pcRet ) )
{
pc--;
sRetLen--;
}
}
if( sRetLen == 0 )
hb_retc( NULL );
else
hb_retclen( pcRet, sRetLen );
}
else /* if (ISCHAR (1)) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
sulErrorSubcodes[iSwitch],
NULL, ( char * ) HB_ERR_FUNCNAME, 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| remove.c | 70 |
HB_FUNC | REMALL(void)
HB_FUNC( REMALL )
{
do_remove( DO_REMOVE_REMALL );
}
| remove.c | 165 |
HB_FUNC | REMLEFT(void)
HB_FUNC( REMLEFT )
{
do_remove( DO_REMOVE_REMLEFT );
}
| remove.c | 199 |
HB_FUNC | REMRIGHT(void)
HB_FUNC( REMRIGHT )
{
do_remove( DO_REMOVE_REMRIGHT );
}
| remove.c | 233 |
replace.c |
Type | Function | Source | Line |
STATIC VOID | do_replace( int iSwitch )
static void do_replace( int iSwitch )
{
/* suppressing return value ? */
int iNoRet = ct_getref() && ISBYREF( 1 );
/* param check */
if( ISCHAR( 1 ) && ( hb_parclen( 2 ) > 0 || ISNUM( 2 ) ) )
{
char *pcString = ( char * ) hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcRet, *pc;
char cSearch, cReplace;
if( sStrLen == 0 )
{
if( iNoRet )
hb_ret();
else
hb_retc( NULL );
return;
}
if( ISNUM( 2 ) )
cReplace = ( char ) ( hb_parnl( 2 ) % 256 );
else
cReplace = *( ( char * ) hb_parc( 2 ) );
if( hb_parclen( 3 ) > 0 )
cSearch = *( ( char * ) hb_parc( 3 ) );
else if( ISNUM( 3 ) )
cSearch = ( char ) ( hb_parnl( 3 ) % 256 );
else
cSearch = 0x20;
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
hb_xmemcpy( pcRet, pcString, sStrLen );
if( iSwitch != DO_REPLACE_REPLRIGHT )
{
pc = pcRet;
while( *pc == cSearch && pc < pcRet + sStrLen )
{
*pc = cReplace;
pc++;
}
}
if( iSwitch != DO_REPLACE_REPLLEFT )
{
pc = pcRet + sStrLen - 1;
while( *pc == cSearch && pc >= pcRet )
{
*pc = cReplace;
pc--;
}
}
if( ISBYREF( 1 ) )
hb_storclen( pcRet, sStrLen, 1 );
if( iNoRet )
{
hb_xfree( pcRet );
hb_ret();
}
else
hb_retclen_buffer( pcRet, sStrLen );
}
else /* ISCHAR( 1 ) && ( hb_parclen( 2 ) > 0 || ISNUM( 2 ) ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
sulErrorSubcodes[iSwitch],
NULL, HB_ERR_FUNCNAME, 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_ret();
else
hb_retc( NULL );
}
}
| replace.c | 70 |
HB_FUNC | REPLALL(void)
HB_FUNC( REPLALL )
{
do_replace( DO_REPLACE_REPLALL );
}
| replace.c | 191 |
HB_FUNC | REPLLEFT(void)
HB_FUNC( REPLLEFT )
{
do_replace( DO_REPLACE_REPLLEFT );
}
| replace.c | 225 |
HB_FUNC | REPLRIGHT(void)
HB_FUNC( REPLRIGHT )
{
do_replace( DO_REPLACE_REPLRIGHT );
}
| replace.c | 259 |
screen1.c |
Type | Function | Source | Line |
HB_FUNC | SCREENATTR(void)
HB_FUNC( SCREENATTR )
{
SHORT sRow, sCol;
int iRow, iCol;
BYTE bColor, bAttr;
USHORT usChar;
hb_gtGetPos( &sRow, &sCol );
iRow = ISNUM( 1 ) ? hb_parni( 1 ) : sRow;
iCol = ISNUM( 2 ) ? hb_parni( 2 ) : sCol;
if( hb_gtGetChar( iRow, iCol, &bColor, &bAttr, &usChar ) != SUCCESS )
bColor = 0;
hb_retni( ( int ) bColor );
}
| screen1.c | 102 |
HB_FUNC | SCREENMIX(void)
HB_FUNC( SCREENMIX )
{
ULONG ulLen = hb_parclen( 1 );
if( ulLen )
{
char * szText = hb_parc( 1 ), * szAttr;
ULONG ulAttr = hb_parclen( 2 ), ul = 0;
SHORT sRow, sCol;
int iRow, iCol, i;
if( ulAttr == 0 )
{
szAttr = " ";
ulAttr = 1;
}
else
szAttr = hb_parc( 2 );
hb_gtGetPos( &sRow, &sCol );
iRow = ISNUM( 3 ) ? hb_parni( 3 ) : sRow;
iCol = ISNUM( 4 ) ? hb_parni( 4 ) : sCol;
if( iRow >= 0 && iCol >= 0 &&
iRow <= hb_gtMaxRow() && iCol <= hb_gtMaxCol() )
{
hb_gtBeginWrite();
i = iCol;
do
{
if( hb_gtPutChar( iRow, i++, szAttr[ ul ], 0, *szText++ ) != SUCCESS )
{
if( ++iRow > hb_gtMaxRow() )
break;
--szText;
++ulLen;
i = iCol;
}
else if( ++ul == ulAttr )
ul = 0;
}
while( --ulLen );
hb_gtEndWrite();
}
}
hb_retc( NULL );
}
| screen1.c | 145 |
HB_FUNC | SAYSCREEN(void)
HB_FUNC( SAYSCREEN )
{
ULONG ulLen = hb_parclen( 1 );
if( ulLen )
{
char * szText = hb_parc( 1 );
SHORT sRow, sCol;
int iRow, iCol, i;
hb_gtGetPos( &sRow, &sCol );
iRow = ISNUM( 2 ) ? hb_parni( 2 ) : sRow;
iCol = ISNUM( 3 ) ? hb_parni( 3 ) : sCol;
if( iRow >= 0 && iCol >= 0 &&
iRow <= hb_gtMaxRow() && iCol <= hb_gtMaxCol() )
{
hb_gtBeginWrite();
i = iCol;
do
{
BYTE bColor, bAttr;
USHORT usChar;
if( hb_gtGetChar( iRow, i, &bColor, &bAttr, &usChar ) != SUCCESS )
{
if( ++iRow > hb_gtMaxRow() )
break;
++ulLen;
i = iCol;
}
else
hb_gtPutChar( iRow, i++, bColor, bAttr, *szText++ );
}
while( --ulLen );
hb_gtEndWrite();
}
}
hb_retc( NULL );
}
| screen1.c | 226 |
STATIC BOOL | hb_ctGetWinCord( int * piTop, int * piLeft, int * piBottom, int * piRight )
static BOOL hb_ctGetWinCord( int * piTop, int * piLeft,
int * piBottom, int * piRight )
{
int iMaxRow = hb_gtMaxRow();
int iMaxCol = hb_gtMaxCol();
hb_gtGetPosEx( piTop, piLeft );
if( ISNUM( 1 ) )
*piTop = hb_parni( 1 );
if( ISNUM( 2 ) )
*piLeft = hb_parni( 2 );
if( ISNUM( 3 ) )
{
*piBottom = hb_parni( 3 );
if( *piBottom > iMaxRow )
*piBottom = iMaxRow;
}
else
*piBottom = iMaxRow;
if( ISNUM( 4 ) )
{
*piRight = hb_parni( 4 );
if( *piRight > iMaxCol )
*piRight = iMaxCol;
}
else
*piRight = iMaxCol;
return *piTop >= 0 && *piLeft >= 0 &&
*piTop <= *piBottom && *piLeft <= *piRight;
}
| screen1.c | 267 |
STATIC INT | hb_ctGetClearChar( int iParam )
static int hb_ctGetClearChar( int iParam )
{
int iChar;
if( ISNUM( iParam ) )
iChar = hb_parni( iParam );
else if( ISCHAR( iParam ) )
iChar = ( UCHAR ) hb_parc( iParam )[0];
else
iChar = hb_gtGetClearChar();
return iChar;
}
| screen1.c | 300 |
STATIC INT | hb_ctGetClearColor( int iParam )
static int hb_ctGetClearColor( int iParam )
{
int iColor;
if( ISNUM( iParam ) )
iColor = hb_parni( iParam );
else if( ISCHAR( iParam ) )
{
iColor = hb_gtColorToN( hb_parc( iParam ) );
if( iColor == -1 )
iColor = 0;
}
else
iColor = hb_gtGetClearColor();
return iColor;
}
| screen1.c | 314 |
HB_FUNC | CLEARWIN(void)
HB_FUNC( CLEARWIN )
{
int iTop, iLeft, iBottom, iRight;
if( hb_ctGetWinCord( &iTop, &iLeft, &iBottom, &iRight ) )
{
BYTE bColor, bChar;
bColor = ( BYTE ) hb_ctGetClearColor( 5 );
bChar = ( BYTE ) hb_ctGetClearChar( 6 );
hb_gtScrollEx( iTop, iLeft, iBottom, iRight, bColor, bChar, 0, 0 );
}
hb_retc( NULL );
}
| screen1.c | 332 |
HB_FUNC | INVERTWIN(void)
HB_FUNC( INVERTWIN )
{
int iTop, iLeft, iBottom, iRight;
if( hb_ctGetWinCord( &iTop, &iLeft, &iBottom, &iRight ) )
{
hb_gtBeginWrite();
while( iTop <= iBottom )
{
int iCol = iLeft;
while( iCol <= iRight )
{
BYTE bColor, bAttr;
USHORT usChar;
hb_gtGetChar( iTop, iCol, &bColor, &bAttr, &usChar );
bColor = ( bColor & 0x88 ) |
( ( bColor & 0x07 ) << 4 ) |
( ( bColor >> 4 ) & 0x07 );
hb_gtPutChar( iTop, iCol, bColor, bAttr, usChar );
++iCol;
}
++iTop;
}
hb_gtEndWrite();
}
hb_retc( NULL );
}
| screen1.c | 377 |
HB_FUNC | UNTEXTWIN(void)
HB_FUNC( UNTEXTWIN )
{
int iTop, iLeft, iBottom, iRight;
UCHAR ucRepl, ucInit, ucEnd;
if( hb_ctGetWinCord( &iTop, &iLeft, &iBottom, &iRight ) )
{
ucRepl = ( UCHAR ) hb_ctGetClearChar( 5 );
if( ISNUM( 6 ) )
ucInit = ( UCHAR ) hb_parni( 6 );
else if( hb_parclen( 6 ) > 0 )
ucInit = ( UCHAR ) hb_parc( 6 )[0];
else
ucInit = 176;
if( ISNUM( 7 ) )
ucEnd = ( UCHAR ) hb_parni( 7 );
else if( hb_parclen( 7 ) > 0 )
ucEnd = ( UCHAR ) hb_parc( 7 )[0];
else
ucEnd = 223;
hb_gtBeginWrite();
while( iTop <= iBottom )
{
int iCol = iLeft;
while( iCol <= iRight )
{
BYTE bColor, bAttr;
USHORT usChar;
hb_gtGetChar( iTop, iCol, &bColor, &bAttr, &usChar );
if( ucInit <= ucEnd ? ( usChar < ucInit || usChar > ucEnd ) :
( usChar > ucEnd && usChar < ucInit ) )
hb_gtPutChar( iTop, iCol, bColor, bAttr, ucRepl );
++iCol;
}
++iTop;
}
hb_gtEndWrite();
}
hb_retc( NULL );
}
| screen1.c | 456 |
HB_FUNC | CHARWIN(void)
HB_FUNC( CHARWIN )
{
int iTop, iLeft, iBottom, iRight;
if( hb_ctGetWinCord( &iTop, &iLeft, &iBottom, &iRight ) )
{
UCHAR ucNewChar, ucOldChar = 0;
BOOL fAll = FALSE;
ucNewChar = ( UCHAR ) hb_ctGetClearChar( 5 );
if( ISNUM( 6 ) )
ucOldChar = ( UCHAR ) hb_parni( 6 );
else if( hb_parclen( 6 ) > 0 )
ucOldChar = ( UCHAR ) hb_parc( 6 )[0];
else
fAll = TRUE;
hb_gtBeginWrite();
while( iTop <= iBottom )
{
int iCol = iLeft;
while( iCol <= iRight )
{
BYTE bColor, bAttr;
USHORT usChar;
hb_gtGetChar( iTop, iCol, &bColor, &bAttr, &usChar );
if( fAll || usChar == ucOldChar )
hb_gtPutChar( iTop, iCol, bColor, bAttr, ucNewChar );
++iCol;
}
++iTop;
}
hb_gtEndWrite();
}
hb_retc( NULL );
}
| screen1.c | 540 |
HB_FUNC | COLORWIN(void)
HB_FUNC( COLORWIN )
{
int iTop, iLeft, iBottom, iRight;
if( hb_ctGetWinCord( &iTop, &iLeft, &iBottom, &iRight ) )
{
UCHAR ucNewColor, ucOldColor = 0;
BOOL fAll = FALSE;
ucNewColor = ( UCHAR ) hb_ctGetClearColor( 5 );
if( ISNUM( 6 ) || ISCHAR( 6 ) )
ucOldColor = ( UCHAR ) hb_ctGetClearColor( 6 );
else
fAll = TRUE;
hb_gtBeginWrite();
while( iTop <= iBottom )
{
int iCol = iLeft;
while( iCol <= iRight )
{
BYTE bColor, bAttr;
USHORT usChar;
hb_gtGetChar( iTop, iCol, &bColor, &bAttr, &usChar );
if( fAll || bColor == ucOldColor )
hb_gtPutChar( iTop, iCol, ucNewColor, bAttr, usChar );
++iCol;
}
++iTop;
}
hb_gtEndWrite();
}
hb_retc( NULL );
}
| screen1.c | 621 |
HB_FUNC | SCREENTEXT(void)
HB_FUNC( SCREENTEXT )
{
int iTop, iLeft, iBottom, iRight;
char * pBuffer, * szText;
ULONG ulSize;
if( hb_ctGetWinCord( &iTop, &iLeft, &iBottom, &iRight ) )
{
ulSize = ( ULONG ) ( iBottom - iTop + 1 ) * ( iRight - iLeft + 1 );
szText = pBuffer = ( char * ) hb_xgrab( ulSize + 1 );
while( iTop <= iBottom )
{
int iCol = iLeft;
while( iCol <= iRight )
{
BYTE bColor, bAttr;
USHORT usChar;
hb_gtGetChar( iTop, iCol, &bColor, &bAttr, &usChar );
*szText++ = ( char ) usChar;
++iCol;
}
++iTop;
}
hb_retclen_buffer( pBuffer, ulSize );
}
else
hb_retc( NULL );
}
| screen1.c | 691 |
HB_FUNC | COLORREPL(void)
HB_FUNC( COLORREPL )
{
int iMaxRow = hb_gtMaxRow();
int iMaxCol = hb_gtMaxCol();
int iRow = 0, iCol;
UCHAR ucNewColor, ucOldColor = 0;
BOOL fAll = FALSE;
ucNewColor = ( UCHAR ) hb_ctGetClearColor( 1 );
if( ISNUM( 2 ) || ISCHAR( 2 ) )
ucOldColor = ( UCHAR ) hb_ctGetClearColor( 2 );
else
fAll = TRUE;
hb_gtBeginWrite();
while( iRow <= iMaxRow )
{
iCol = 0;
while( iCol <= iMaxCol )
{
BYTE bColor, bAttr;
USHORT usChar;
hb_gtGetChar( iRow, iCol, &bColor, &bAttr, &usChar );
if( fAll || bColor == ucOldColor )
hb_gtPutChar( iRow, iCol, ucNewColor, bAttr, usChar );
++iCol;
}
++iRow;
}
hb_gtEndWrite();
hb_retc( NULL );
}
| screen1.c | 751 |
screen2.c |
Type | Function | Source | Line |
HB_FUNC | SAYDOWN(void)
HB_FUNC( SAYDOWN )
{
ULONG ulLen = hb_parclen( 1 );
if( ulLen )
{
UCHAR * szText = ( UCHAR * ) hb_parc( 1 );
SHORT sRow, sCol;
int iRow, iCol, iMaxRow, iMaxCol;
long lDelay;
lDelay = ISNUM( 2 ) ? hb_parnl( 2 ) : 4;
hb_gtGetPos( &sRow, &sCol );
iRow = ISNUM( 3 ) ? hb_parni( 3 ) : ( int ) sRow;
iCol = ISNUM( 4 ) ? hb_parni( 4 ) : ( int ) sCol;
iMaxRow = hb_gtMaxRow();
iMaxCol = hb_gtMaxCol();
if( iRow >= 0 && iCol >= 0 && iRow <= iMaxRow && iCol <= iMaxCol )
{
BYTE bColor = hb_gtGetCurrColor();
if( ulLen > ( ULONG ) ( iMaxRow - iRow + 1 ) )
ulLen = ( ULONG ) ( iMaxRow - iRow + 1 );
hb_gtBeginWrite();
while( ulLen-- )
{
hb_gtPutChar( iRow++, iCol, bColor, 0, *szText++ );
if( lDelay )
{
hb_gtEndWrite();
hb_idleSleep( ( double ) lDelay / 1000 );
hb_gtBeginWrite();
}
}
hb_gtEndWrite();
}
}
hb_retc( NULL );
}
| screen2.c | 59 |
HB_FUNC | SAYSPREAD(void)
HB_FUNC( SAYSPREAD )
{
ULONG ulLen = hb_parclen( 1 );
if( ulLen )
{
UCHAR * szText = ( UCHAR * ) hb_parc( 1 );
ULONG ulPos, ul;
SHORT sRow, sCol;
int iRow, iCol, iMaxRow, iMaxCol;
long lDelay;
lDelay = ISNUM( 2 ) ? hb_parnl( 2 ) : 4;
iMaxRow = hb_gtMaxRow();
iMaxCol = hb_gtMaxCol();
hb_gtGetPos( &sRow, &sCol );
iRow = ISNUM( 3 ) ? hb_parni( 3 ) : ( int ) sRow;
iCol = ISNUM( 4 ) ? hb_parni( 4 ) : ( iMaxCol >> 1 );
if( iRow >= 0 && iCol >= 0 && iRow <= iMaxRow && iCol <= iMaxCol )
{
BYTE bColor = hb_gtGetCurrColor();
ulPos = ulLen >> 1;
ulLen = ulLen & 1;
if( !ulLen )
{
ulLen = 2;
--ulPos;
}
hb_gtBeginWrite();
do
{
for( ul = 0; ul < ulLen && iCol + ( int ) ul <= iMaxCol; ++ul )
hb_gtPutChar( iRow, iCol + ( int ) ul, bColor, 0, szText[ulPos + ul] );
ulLen += 2;
if( lDelay )
{
hb_gtEndWrite();
hb_idleSleep( ( double ) lDelay / 1000 );
hb_gtBeginWrite();
}
}
while( ulPos-- && iCol-- );
/* CT3 does not respect iCol in the above condition */
hb_gtEndWrite();
}
}
hb_retc( NULL );
}
| screen2.c | 103 |
HB_FUNC | SAYMOVEIN(void)
HB_FUNC( SAYMOVEIN )
{
ULONG ulLen = hb_parclen( 1 );
if( ulLen )
{
UCHAR * szText = ( UCHAR * ) hb_parc( 1 );
ULONG ulChars, ul;
SHORT sRow, sCol;
int iRow, iCol, iMaxRow, iMaxCol;
long lDelay;
BOOL fBack;
lDelay = ISNUM( 2 ) ? hb_parnl( 2 ) : 4;
fBack = ISLOG( 5 ) && hb_parl( 5 );
iMaxRow = hb_gtMaxRow();
iMaxCol = hb_gtMaxCol();
hb_gtGetPos( &sRow, &sCol );
iRow = ISNUM( 3 ) ? hb_parni( 3 ) : ( int ) sRow;
iCol = ISNUM( 4 ) ? hb_parni( 4 ) : ( int ) sCol;
if( iRow >= 0 && iCol >= 0 && iRow <= iMaxRow && iCol <= iMaxCol )
{
BYTE bColor = hb_gtGetCurrColor();
sRow = iRow;
sCol = iCol + ( int ) ulLen;
if( fBack )
iCol += ulLen - 1;
else
szText += ulLen - 1;
ulChars = 1;
hb_gtBeginWrite();
do
{
if( fBack )
{
if( iCol <= iMaxCol )
{
for( ul = 0; ul < ulChars; ++ul )
hb_gtPutChar( iRow, iCol + ( int ) ul, bColor, 0, szText[ul] );
}
--iCol;
}
else
{
for( ul = 0; ul < ulChars; ++ul )
hb_gtPutChar( iRow, iCol + ( int ) ul, bColor, 0, szText[ul] );
--szText;
}
if( ( int ) ulChars + iCol <= iMaxCol )
++ulChars;
if( lDelay )
{
hb_gtEndWrite();
hb_idleSleep( ( double ) lDelay / 1000 );
hb_gtBeginWrite();
}
}
while( --ulLen );
hb_gtSetPos( sRow, sCol );
hb_gtEndWrite();
}
}
hb_retc( NULL );
}
| screen2.c | 157 |
HB_FUNC | CLEARSLOW(void)
HB_FUNC( CLEARSLOW )
{
int iMaxRow = hb_gtMaxRow();
int iMaxCol = hb_gtMaxCol();
int iTop, iLeft, iBottom, iRight;
UCHAR ucChar;
long lDelay;
lDelay = hb_parnl( 1 );
iTop = hb_parni( 2 );
iLeft = hb_parni( 3 );
iBottom = ISNUM( 4 ) ? hb_parni( 4 ) : iMaxRow;
iRight = ISNUM( 5 ) ? hb_parni( 5 ) : iMaxCol;
if( ISNUM( 6 ) )
ucChar = ( UCHAR ) hb_parni( 6 );
else if( ISCHAR( 6 ) )
ucChar = ( UCHAR ) hb_parc( 6 )[0];
else
ucChar = ( UCHAR ) hb_gtGetClearChar();
if( iTop >= 0 && iLeft >= 0 && iTop <= iBottom && iLeft <= iRight )
{
BYTE pbFrame[2], bColor = ( BYTE ) hb_gtGetCurrColor();
double dX, dY, dXX, dYY;
pbFrame[0] = ucChar;
pbFrame[1] = '\0';
dX = iRight - iLeft + 1;
dY = iBottom - iTop + 1;
if( dX > dY )
{
dY /= dX;
dX = 1;
}
else
{
dX /= dY;
dY = 1;
}
dXX = dYY = 0;
hb_gtBeginWrite();
while( TRUE )
{
hb_gtBoxEx( iTop, iLeft, iBottom, iRight, pbFrame, bColor );
if( lDelay )
{
hb_gtEndWrite();
hb_idleSleep( ( double ) lDelay / 1000 );
hb_gtBeginWrite();
}
if( iTop >= iBottom && iLeft >= iRight )
break;
if( iTop < iBottom )
{
dYY += dY;
if( dYY >= 1 )
{
iTop++;
if( iBottom > iTop )
iBottom--;
dYY -= 1;
}
}
if( iLeft < iRight )
{
dXX += dX;
if( dXX >= 1 )
{
iLeft++;
if( iRight > iLeft )
iRight--;
}
}
}
hb_gtEndWrite();
}
}
| screen2.c | 228 |
HB_FUNC | SCREENSTR(void)
HB_FUNC( SCREENSTR )
{
SHORT sRow, sCol, sMaxRow, sMaxCol, sC;
char * pBuffer, * szText;
ULONG ulSize, ulCount = ULONG_MAX;
hb_gtGetPos( &sRow, &sCol );
if( ISNUM( 1 ) )
sRow = ( SHORT ) hb_parni( 1 );
if( ISNUM( 2 ) )
sCol = ( SHORT ) hb_parni( 2 );
if( ISNUM( 3 ) )
ulCount = hb_parnl( 3 );
sMaxRow = ( SHORT ) hb_gtMaxRow();
sMaxCol = ( SHORT ) hb_gtMaxCol();
if( sRow >= 0 && sRow <= sMaxRow && sCol >= 0 && sCol <= sMaxCol && ulCount )
{
ulSize = ( ULONG ) ( sMaxRow - sRow + 1 ) * ( sMaxCol - sCol + 1 );
if( ulSize > ulCount )
ulSize = ulCount;
ulCount = ulSize;
ulSize <<= 1;
szText = pBuffer = ( char * ) hb_xgrab( ulSize + 1 );
do
{
sC = sCol;
do
{
BYTE bColor, bAttr;
USHORT usChar;
hb_gtGetChar( sRow, sC, &bColor, &bAttr, &usChar );
*szText++ = ( char ) usChar;
*szText++ = ( char ) bColor;
}
while( --ulCount && ++sC <= sMaxCol );
}
while( ulCount && ++sRow <= sMaxRow );
hb_retclen_buffer( pBuffer, ulSize );
}
else
hb_retc( NULL );
}
| screen2.c | 312 |
HB_FUNC | STRSCREEN(void)
HB_FUNC( STRSCREEN )
{
ULONG ulLen = hb_parclen( 1 );
if( ulLen & 1 )
ulLen--;
if( ulLen )
{
UCHAR * szText = ( UCHAR * ) hb_parc( 1 );
SHORT sRow, sCol, sMaxRow, sMaxCol, sC;
hb_gtGetPos( &sRow, &sCol );
if( ISNUM( 2 ) )
sRow = ( SHORT ) hb_parni( 2 );
if( ISNUM( 3 ) )
sCol = ( SHORT ) hb_parni( 3 );
sMaxRow = ( SHORT ) hb_gtMaxRow();
sMaxCol = ( SHORT ) hb_gtMaxCol();
if( sRow >= 0 && sRow <= sMaxRow && sCol >= 0 && sCol <= sMaxCol )
{
hb_gtBeginWrite();
do
{
sC = sCol;
do
{
USHORT usChar = *szText++;
BYTE bColor = *szText++;
hb_gtPutChar( sRow, sC, bColor, 0, usChar );
ulLen -= 2;
}
while( ulLen && ++sC <= sMaxCol );
}
while( ulLen && ++sRow <= sMaxRow );
hb_gtEndWrite();
}
}
hb_retc( NULL );
}
| screen2.c | 357 |
HB_FUNC | _HB_CTDSPTIME(void)
HB_FUNC( _HB_CTDSPTIME )
{
SHORT sRow, sCol;
int iColor, iLen, i;
char szTime[ 10 ];
sRow = ( SHORT ) hb_parni( 1 );
sCol = ( SHORT ) hb_parni( 2 );
if( ISNUM( 4 ) )
iColor = hb_parni( 4 );
else if( ISCHAR( 4 ) )
{
iColor = hb_gtColorToN( hb_parc( 4 ) );
if( iColor == -1 )
iColor = 0;
}
else
iColor = hb_gtGetClearColor();
hb_dateTimeStr( szTime );
iLen = 8;
if( ISLOG( 3 ) && hb_parl( 3 ) )
iLen -= 3;
if( ISLOG( 5 ) && hb_parl( 5 ) )
{
int iHour = ( szTime[0] - '0' ) * 10 + ( szTime[1] - '0' );
if( ISLOG( 6 ) && hb_parl( 6 ) )
szTime[iLen++] = iHour >= 12 ? 'p' : 'a';
if( iHour > 12 )
iHour -= 12;
else if( iHour == 0 )
iHour = 12;
szTime[0] = ( iHour / 10 ) + '0';
szTime[1] = ( iHour % 10 ) + '0';
}
if( szTime[0] == '0' )
szTime[0] = ' ';
hb_gtDispBegin();
for( i = 0; i < iLen; ++sCol, ++i )
hb_gtPutScrChar( sRow, sCol, iColor, 0, szTime[i] );
hb_gtDispEnd();
}
| screen2.c | 400 |
setlast.c |
Type | Function | Source | Line |
HB_FUNC | SETLASTKEY(void)
HB_FUNC( SETLASTKEY )
{
hb_inkeySetLast( hb_parni( 1 ) );
hb_retc( NULL );
}
| setlast.c | 56 |
setrc.c |
Type | Function | Source | Line |
HB_FUNC | SETRC(void)
HB_FUNC( SETRC )
{
BOOL fRow = ISNUM( 1 ), fCol = ISNUM( 2 );
if( fRow && fCol )
hb_gtSetPos( hb_parni( 1 ), hb_parni( 2 ) );
else
{
SHORT sRow, sCol;
hb_gtGetPos( &sRow, &sCol );
hb_gtSetPos( fRow ? hb_parni( 1 ) : sRow, fCol ? hb_parni( 2 ) : sCol );
}
hb_retc( NULL );
}
| setrc.c | 55 |
strdiff.c |
Type | Function | Source | Line |
STATIC INT | min3( int a, int b, int c )
static int min3( int a, int b, int c )
{
if( a < b )
{
return ( ( a < c ? a : c ) );
}
return ( ( b < c ? b : c ) );
}
| strdiff.c | 130 |
HB_FUNC | STRDIFF(void)
HB_FUNC( STRDIFF )
{
/* param check */
if( ISCHAR( 1 ) || ISCHAR( 2 ) )
{
/* get parameters */
char *pcStr1, *pcStr2;
size_t sStrLen1, sStrLen2;
int iReplace, iDelete, iInsert;
int iAtLike = ct_getatlike();
char cAtLike = ct_getatlikechar();
int *piPenalty;
size_t sRowCnt, sColCnt;
if( ISCHAR( 1 ) )
{
pcStr1 = ( char * ) hb_parc( 1 );
sStrLen1 = ( size_t ) hb_parclen( 1 );
}
else
{
pcStr1 = ( char * ) "";
sStrLen1 = 0;
}
if( ISCHAR( 2 ) )
{
pcStr2 = ( char * ) hb_parc( 2 );
sStrLen2 = ( size_t ) hb_parclen( 2 );
}
else
{
pcStr2 = ( char * ) "";
sStrLen2 = 0;
}
/* check for memory consumption */
if( ( ( double ) sStrLen1 + 1.0 ) *
( ( double ) sStrLen2 + 1.0 ) *
( ( double ) sizeof( int ) ) >= ( double ) UINT_MAX )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_STRDIFF, NULL,
"STRDIFF", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( -1 );
return;
}
/* get penalty points */
if( ISNUM( 3 ) )
iReplace = hb_parni( 3 );
else
iReplace = 3;
if( ISNUM( 4 ) )
iDelete = hb_parni( 4 );
else
iDelete = 6;
if( ISNUM( 5 ) )
iInsert = hb_parni( 5 );
else
iInsert = 1;
piPenalty = ( int * ) hb_xgrab( ( sStrLen1 + 1 ) *
( sStrLen2 + 1 ) * sizeof( int ) );
MATRIXELEMENT( 0, 0 ) = 0;
for( sColCnt = 0; sColCnt <= sStrLen2 - 1; sColCnt++ )
{
MATRIXELEMENT( 0, sColCnt + 1 ) = MATRIXELEMENT( 0, sColCnt ) + iInsert;
}
for( sRowCnt = 0; sRowCnt <= sStrLen1 - 1; sRowCnt++ )
{
MATRIXELEMENT( sRowCnt + 1, 0 ) = MATRIXELEMENT( sRowCnt, 0 ) + iDelete;
for( sColCnt = 0; sColCnt <= sStrLen2 - 1; sColCnt++ )
{
int iReplaceCost;
if( pcStr1[sRowCnt] == pcStr2[sColCnt] ||
( iAtLike == CT_SETATLIKE_WILDCARD &&
( pcStr1[sRowCnt] == cAtLike ||
pcStr2[sColCnt] == cAtLike ) ) )
iReplaceCost = 0;
else
iReplaceCost = iReplace;
MATRIXELEMENT( sRowCnt + 1, sColCnt + 1 ) =
min3( MATRIXELEMENT( sRowCnt, sColCnt ) + iReplaceCost,
MATRIXELEMENT( sRowCnt, sColCnt + 1 ) + iDelete,
MATRIXELEMENT( sRowCnt + 1, sColCnt ) + iInsert );
}
}
hb_retni( MATRIXELEMENT( sStrLen1, sStrLen2 ) );
hb_xfree( piPenalty );
}
else /* ISCHAR( 1 ) || ISCHAR( 2 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_STRDIFF, NULL, "STRDIFF", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| strdiff.c | 139 |
strswap.c |
Type | Function | Source | Line |
HB_FUNC | STRSWAP(void)
HB_FUNC( STRSWAP )
{
size_t sStrLen1, sStrLen2;
/* param check */
if( ( sStrLen1 = ( size_t ) hb_parclen( 1 ) ) > 0 &&
( sStrLen2 = ( size_t ) hb_parclen( 2 ) ) > 0 )
{
/* get parameters */
char *pcString1 = ( char * ) hb_parc( 1 );
char *pcString2 = ( char * ) hb_parc( 2 );
char *pcRet1 = NULL, *pcRet2 = NULL;
int iChange1, iChange2;
size_t sIndex, sCmpLen;
if( ( iChange1 = ISBYREF( 1 ) ) != 0 )
{
pcRet1 = ( char * ) hb_xgrab( sStrLen1 );
hb_xmemcpy( pcRet1, pcString1, sStrLen1 );
}
if( ( iChange2 = ISBYREF( 2 ) ) != 0 )
{
pcRet2 = ( char * ) hb_xgrab( sStrLen2 );
hb_xmemcpy( pcRet2, pcString2, sStrLen2 );
}
sCmpLen = ( sStrLen1 < sStrLen2 ? sStrLen1 : sStrLen2 );
for( sIndex = 0; sIndex < sCmpLen; sIndex++ )
{
char cExchange;
if( iChange1 )
{
cExchange = *( pcString1 + sIndex );
*( pcRet1 + sIndex ) = *( pcString2 + sIndex );
if( iChange2 )
{
*( pcRet2 + sIndex ) = cExchange;
}
}
else
{
*( pcRet2 + sIndex ) = *( pcString1 + sIndex );
}
}
/* strings */
if( iChange1 )
{
hb_storclen( pcRet1, sStrLen1, 1 );
hb_xfree( pcRet1 );
}
if( iChange2 )
{
hb_storclen( pcRet2, sStrLen2, 2 );
hb_xfree( pcRet2 );
}
hb_retc( NULL );
}
else /* ( sStrLen1 = ( size_t ) hb_parclen( 1 ) ) > 0 &&
( sStrLen2 = ( size_t ) hb_parclen( 2 ) ) > 0 */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_STRSWAP, NULL, "STRSWAP", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| strswap.c | 86 |
tab.c |
Type | Function | Source | Line |
HB_FUNC | TABEXPAND(void)
HB_FUNC( TABEXPAND )
{
if( ISCHAR( 1 ) )
{
char *pcString = ( char * ) hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcRet;
size_t sRetLen;
size_t sTabWidth = 0;
char cFill, cTab, cCR;
char *pcNewLine;
size_t sNewLineLen;
int iIgnore141;
size_t sIndex, sLineIndex;
size_t sTabCnt = 0;
if( ISNUM( 2 ) )
sTabWidth = hb_parnl( 2 );
if( ( signed ) sTabWidth <= 0 )
sTabWidth = 8;
if( ISNUM( 3 ) )
cFill = ( char ) ( hb_parnl( 3 ) % 256 );
else if( hb_parclen( 3 ) > 0 )
cFill = hb_parc( 3 )[0];
else
cFill = 0x20;
if( ISCHAR( 4 ) && hb_parclen( 4 ) > 0 )
{
pcNewLine = ( char * ) hb_parc( 4 );
sNewLineLen = hb_parclen( 4 );
}
else
{
pcNewLine = hb_conNewLine();
sNewLineLen = 0;
while( *( pcNewLine + sNewLineLen ) != 0x00 )
sNewLineLen++;
}
if( sNewLineLen > 0 )
cCR = *( pcNewLine );
else
cCR = 13;
if( ISNUM( 5 ) )
cTab = ( char ) ( hb_parnl( 5 ) % 256 );
else if( hb_parclen( 5 ) > 0 )
cTab = hb_parc( 5 )[0];
else
cTab = 0x09;
if( ISLOG( 6 ) )
iIgnore141 = hb_parl( 6 );
else
iIgnore141 = 0;
/* estimate maximum return length by assuming that EVERY tab char
can be replaced by at most characters */
for( sIndex = 0; sIndex < sStrLen; sIndex++ )
{
if( *( pcString + sIndex ) == cTab )
sTabCnt++;
}
if( sTabCnt == 0 )
{
hb_retclen( pcString, sStrLen );
return;
}
pcRet = ( char * ) hb_xgrab( sStrLen + ( sTabCnt * ( sTabWidth - 1 ) ) );
/* now copy the string */
sIndex = 0;
sRetLen = 0;
sLineIndex = 0;
while( sTabCnt > 0 )
{
char cChar = ( char ) *( pcString + sIndex );
if( cChar == cTab )
{
/* tab character */
size_t sFillIndex;
for( sFillIndex = sTabWidth - ( sLineIndex % sTabWidth ); sFillIndex > 0; sFillIndex-- )
{
*( pcRet + sRetLen ) = cFill;
sRetLen++;
sLineIndex++;
}
sTabCnt--;
sIndex++;
}
else if( ( unsigned char ) cChar == 141 )
{
/* soft carriage return */
*( pcRet + sRetLen ) = ( char ) 141;
sRetLen++;
sIndex++;
if( iIgnore141 )
sLineIndex++;
else
sLineIndex = 0;
}
else if( cChar == cCR )
{
/* newline string ? */
if( sNewLineLen > 0 &&
sIndex + sNewLineLen <= sStrLen &&
ct_at_exact_forward( pcString + sIndex, sNewLineLen, pcNewLine,
sNewLineLen, NULL ) == pcString + sIndex )
{
hb_xmemcpy( pcRet + sRetLen, pcString + sIndex, sNewLineLen );
sRetLen += sNewLineLen;
sIndex += sNewLineLen;
sLineIndex = 0;
}
else
{
*( pcRet + sRetLen ) = cCR;
sRetLen++;
sIndex++;
sLineIndex++;
}
}
else
{
*( pcRet + sRetLen ) = *( pcString + sIndex );
sRetLen++;
sIndex++;
sLineIndex++;
}
}
/* copy rest */
hb_xmemcpy( pcRet + sRetLen, pcString + sIndex, sStrLen - sIndex );
sRetLen += sStrLen - sIndex;
hb_retclen( pcRet, sRetLen );
hb_xfree( pcRet );
}
else /* ISCHAR( 1 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TABEXPAND, NULL, "TABEXPAND", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| tab.c | 109 |
HB_FUNC | TABPACK(void)
HB_FUNC( TABPACK )
{
if( ISCHAR( 1 ) )
{
char *pcString = ( char * ) hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcRet;
size_t sRetLen;
size_t sTabWidth = 0;
char cFill, cTab, cCR;
char *pcNewLine;
size_t sNewLineLen;
int iIgnore141;
size_t sIndex, sTabIndex, sFillCount;
if( ISNUM( 2 ) )
sTabWidth = hb_parnl( 2 );
if( ( signed ) sTabWidth <= 0 )
sTabWidth = 8;
if( ISNUM( 3 ) )
cFill = ( char ) ( hb_parnl( 3 ) % 256 );
else if( hb_parclen( 3 ) > 0 )
cFill = hb_parc( 3 )[0];
else
cFill = 0x20;
sNewLineLen = hb_parclen( 4 );
if( sNewLineLen > 0 )
pcNewLine = ( char * ) hb_parc( 4 );
else
{
pcNewLine = hb_conNewLine();
sNewLineLen = strlen( pcNewLine );
}
if( sNewLineLen > 0 )
cCR = *( pcNewLine );
else
cCR = 13;
if( ISNUM( 5 ) )
cTab = ( char ) ( hb_parnl( 5 ) % 256 );
else if( hb_parclen( 5 ) > 0 )
cTab = hb_parc( 5 )[0];
else
cTab = 0x09;
if( ISLOG( 6 ) )
iIgnore141 = hb_parl( 6 );
else
iIgnore141 = 0;
if( sStrLen == 0 )
{
hb_retc( NULL );
return;
}
/* estimate maximum return length by assuming that there's
nothing to pack */
pcRet = ( char * ) hb_xgrab( sStrLen );
/* now copy the string */
sIndex = 0;
sRetLen = 0;
sTabIndex = 0;
sFillCount = 0;
while( sIndex < sStrLen )
{
char cChar = ( char ) *( pcString + sIndex );
if( cChar == cFill )
{
if( sTabIndex == sTabWidth - 1 )
{
/* we have just found the last character of a tabstopp */
*( pcRet + sRetLen ) = cTab;
sRetLen++;
sFillCount = 0;
sTabIndex = 0;
sIndex++;
}
else
{
sFillCount++;
sTabIndex++;
sIndex++;
}
}
else if( cChar == cTab )
{
*( pcRet + sRetLen ) = cTab;
sRetLen++;
/* discard any fill characters before the tabstopp */
sFillCount = 0;
sTabIndex = 0;
sIndex++;
}
else if( ( unsigned char ) cChar == 141 && !iIgnore141 )
{
/* soft carriage return */
/* eventually not enough fill chars to fill a tab,
so copy them verbatim */
for( ; sFillCount > 0; sFillCount-- )
{
*( pcRet + sRetLen ) = cFill;
sRetLen++;
}
*( pcRet + sRetLen ) = ( char ) 141;
sRetLen++;
sTabIndex = 0;
sIndex++;
}
else if( cChar == cCR )
{
/* newline string ? */
if( sNewLineLen > 0 &&
sIndex + sNewLineLen <= sStrLen &&
ct_at_exact_forward( pcString + sIndex, sNewLineLen, pcNewLine,
sNewLineLen, NULL ) == pcString + sIndex )
{
/* eventually not enough fill chars to fill a tab,
so copy them verbatim */
for( ; sFillCount > 0; sFillCount-- )
{
*( pcRet + sRetLen ) = cFill;
sRetLen++;
}
hb_xmemcpy( pcRet + sRetLen, pcString + sIndex, sNewLineLen );
sRetLen += sNewLineLen;
sIndex += sNewLineLen;
sTabIndex = 0;
}
else
{
*( pcRet + sRetLen ) = cCR;
sRetLen++;
sIndex++;
sTabIndex = 0;
}
}
else
{
/* eventually not enough fill chars to fill a tab,
so copy them verbatim */
for( ; sFillCount > 0; sFillCount-- )
{
*( pcRet + sRetLen ) = cFill;
sRetLen++;
sTabIndex++;
if( sTabIndex == sTabWidth - 1 )
{
sTabIndex = 0;
}
}
*( pcRet + sRetLen ) = *( pcString + sIndex );
sRetLen++;
sIndex++;
sTabIndex++;
if( sTabIndex == sTabWidth - 1 )
sTabIndex = 0;
}
}
/* copy rest */
for( ; sFillCount > 0; sFillCount-- )
{
*( pcRet + sRetLen ) = cFill;
sRetLen++;
}
hb_retclen( pcRet, sRetLen );
hb_xfree( pcRet );
}
else /* ISCHAR( 1 ) */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TABPACK, NULL, "TABPACK", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| tab.c | 310 |
token1.c |
Type | Function | Source | Line |
STATIC VOID | do_token1( int iSwitch )
static void do_token1( int iSwitch )
{
int iParamCheck = 0;
int iNoRef = ct_getref() && ISBYREF( 1 );
switch ( iSwitch )
{
case DO_TOKEN1_TOKEN:
siPreSeparator = siPostSeparator = -1;
/* no "break" here !! */
case DO_TOKEN1_ATTOKEN:
case DO_TOKEN1_NUMTOKEN:
case DO_TOKEN1_TOKENLOWER:
case DO_TOKEN1_TOKENUPPER:
iParamCheck = ( ISCHAR( 1 ) );
break;
}
if( iParamCheck )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcSeparatorStr;
size_t sSeparatorStrLen;
ULONG ulTokenCounter = 0;
ULONG ulSkip;
char *pcSubStr;
char *pcRet = NULL;
size_t sSubStrLen;
size_t sRetStrLen = 0;
ULONG ulToken = 0;
ULONG ulSkipCnt;
char *pc;
/* separator string */
sSeparatorStrLen = hb_parclen( 2 );
if( sSeparatorStrLen != 0 )
pcSeparatorStr = hb_parc( 2 );
else
{
pcSeparatorStr = ( char * ) spcSeparatorStr;
sSeparatorStrLen = ssSeparatorStrLen;
}
/* token counter */
if( iSwitch != DO_TOKEN1_NUMTOKEN )
ulTokenCounter = hb_parnl( 3 );
if( ulTokenCounter == 0 )
ulTokenCounter = ULONG_MAX;
/* skip width */
if( iSwitch == DO_TOKEN1_NUMTOKEN )
{
if( ISNUM( 3 ) )
ulSkip = hb_parnl( 3 );
else
ulSkip = ULONG_MAX;
}
else
{
if( ISNUM( 4 ) )
ulSkip = hb_parnl( 4 );
else
ulSkip = ULONG_MAX;
}
if( ulSkip == 0 )
ulSkip = ULONG_MAX;
/* prepare return value for TOKENUPPER/TOKENLOWER */
if( iSwitch == DO_TOKEN1_TOKENLOWER || iSwitch == DO_TOKEN1_TOKENUPPER )
{
if( sStrLen == 0 )
{
if( iNoRef )
hb_retl( 0 );
else
hb_retc( NULL );
return;
}
sRetStrLen = sStrLen;
pcRet = ( char * ) hb_xgrab( sRetStrLen + 1 );
hb_xmemcpy( pcRet, pcString, sRetStrLen );
}
/* find the th token */
pcSubStr = pcString;
sSubStrLen = sStrLen;
/* scan start condition */
pc = pcSubStr - 1;
while( ulToken < ulTokenCounter )
{
size_t sMatchedPos = sSeparatorStrLen;
/* Skip the left ulSkip successive separators */
ulSkipCnt = 0;
do
{
sSubStrLen -= ( pc - pcSubStr ) + 1;
pcSubStr = pc + 1;
pc = ct_at_charset_forward( pcSubStr, sSubStrLen,
pcSeparatorStr, sSeparatorStrLen, &sMatchedPos );
if( iSwitch == DO_TOKEN1_TOKEN )
{
siPreSeparator = siPostSeparator;
if( sMatchedPos < sSeparatorStrLen )
siPostSeparator = pcSeparatorStr[sMatchedPos];
else
siPostSeparator = -1;
}
ulSkipCnt++;
}
while( ulSkipCnt < ulSkip && pc == pcSubStr );
if( sSubStrLen == 0 )
{
/* string ends with tokenizer (null string after tokenizer at
end of string is not a token) */
switch ( iSwitch )
{
case DO_TOKEN1_TOKEN:
{
char cRet;
hb_retc( NULL );
if( ISBYREF( 5 ) )
{
cRet = ( char ) siPreSeparator;
hb_storclen( &cRet, ( siPreSeparator != -1 ? 1 : 0 ), 5 );
}
if( ISBYREF( 6 ) )
{
cRet = ( char ) siPostSeparator;
hb_storclen( &cRet, ( siPostSeparator != -1 ? 1 : 0 ), 6 );
}
break;
}
case DO_TOKEN1_NUMTOKEN:
hb_retnl( ulToken );
break;
case DO_TOKEN1_ATTOKEN:
hb_retni( 0 );
break;
case DO_TOKEN1_TOKENLOWER:
case DO_TOKEN1_TOKENUPPER:
if( ISBYREF( 1 ) )
hb_storclen( pcRet, sRetStrLen, 1 );
if( iNoRef )
{
hb_xfree( pcRet );
hb_retl( 0 );
}
else
hb_retclen_buffer( pcRet, sRetStrLen );
break;
}
return;
}
switch ( iSwitch )
{
case DO_TOKEN1_TOKEN:
case DO_TOKEN1_NUMTOKEN:
case DO_TOKEN1_ATTOKEN:
break;
case DO_TOKEN1_TOKENLOWER:
if( pcSubStr != pc ) /* letters can be tokenizers, too,
but they should not be lowercase'd */
*( pcRet + ( pcSubStr - pcString ) ) = hb_charLower( ( UCHAR ) *pcSubStr );
break;
case DO_TOKEN1_TOKENUPPER:
if( pcSubStr != pc ) /* letters can be tokenizers, too,
but they should not be uppercase'd */
*( pcRet + ( pcSubStr - pcString ) ) = hb_charUpper( ( UCHAR ) *pcSubStr );
break;
default:
break;
}
ulToken++;
if( pc == NULL )
{
pc = pcSubStr + sSubStrLen; /* little trick for return values */
break; /* we must leave the while loop even if we have not
yet found the th token */
}
/* should we find the last token, but string ends with tokenizer, i.e.
pc points to the last character at the moment ?
-> break here ! */
if( ulTokenCounter == HB_MKULONG( 255, 255, 255, 255 ) )
{
if( ulSkip == HB_MKULONG( 255, 255, 255, 255 ) )
{
char *t;
BOOL bLast = TRUE;
for( t = pc + 1; t < pcString + sStrLen; t++ )
{
if( !memchr( pcSeparatorStr, *t, sSeparatorStrLen ) )
{
bLast = FALSE;
break;
}
}
if( bLast )
break;
}
else if( pc + 1 == pcString + sStrLen )
break;
}
} /* while( ulToken < ulTokenCounter ) */
switch ( iSwitch )
{
case DO_TOKEN1_TOKEN:
{
char cRet;
if( ( ulTokenCounter == HB_MKULONG( 255, 255, 255, 255 ) ) ||
( ulToken == ulTokenCounter ) )
hb_retclen( pcSubStr, pc - pcSubStr );
else
hb_retc( NULL );
if( ISBYREF( 5 ) )
{
cRet = ( char ) siPreSeparator;
hb_storclen( &cRet, ( siPreSeparator != -1 ? 1 : 0 ), 5 );
}
if( ISBYREF( 6 ) )
{
cRet = ( char ) siPostSeparator;
hb_storclen( &cRet, ( siPostSeparator != -1 ? 1 : 0 ), 6 );
}
break;
}
case DO_TOKEN1_NUMTOKEN:
hb_retnl( ulToken );
break;
case DO_TOKEN1_ATTOKEN:
if( ( ulTokenCounter == HB_MKULONG( 255, 255, 255, 255 ) ) ||
( ulToken == ulTokenCounter ) )
hb_retnl( pcSubStr - pcString + 1 );
else
hb_retni( 0 );
break;
case DO_TOKEN1_TOKENLOWER:
case DO_TOKEN1_TOKENUPPER:
if( ISBYREF( 1 ) )
hb_storclen( pcRet, sRetStrLen, 1 );
if( iNoRef )
{
hb_xfree( pcRet );
hb_retl( 0 );
}
else
hb_retclen_buffer( pcRet, sRetStrLen );
break;
}
}
else /* iParamCheck */
{
switch ( iSwitch )
{
case DO_TOKEN1_TOKEN:
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
char cRet;
if( ISBYREF( 5 ) )
{
cRet = ( char ) siPreSeparator;
hb_storclen( &cRet, ( siPreSeparator != -1 ? 1 : 0 ), 5 );
}
if( ISBYREF( 6 ) )
{
cRet = ( char ) siPostSeparator;
hb_storclen( &cRet, ( siPostSeparator != -1 ? 1 : 0 ), 6 );
}
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TOKEN, NULL, "TOKEN", 0,
EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( !iNoRef )
hb_retc( NULL );
else
hb_retl( 0 );
break;
}
case DO_TOKEN1_TOKENLOWER:
case DO_TOKEN1_TOKENUPPER:
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_TOKEN1_TOKENLOWER ?
CT_ERROR_TOKENLOWER : CT_ERROR_TOKENUPPER,
NULL, HB_ERR_FUNCNAME, 0,
EF_CANSUBSTITUTE,
HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( !iNoRef )
hb_retc( NULL );
else
hb_retl( 0 );
break;
}
case DO_TOKEN1_NUMTOKEN:
case DO_TOKEN1_ATTOKEN:
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
iSwitch == DO_TOKEN1_NUMTOKEN ?
CT_ERROR_NUMTOKEN : CT_ERROR_ATTOKEN,
NULL, HB_ERR_FUNCNAME, 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
break;
}
}
}
}
| token1.c | 83 |
HB_FUNC | ATTOKEN(void)
HB_FUNC( ATTOKEN )
{
do_token1( DO_TOKEN1_ATTOKEN );
}
| token1.c | 503 |
HB_FUNC | TOKEN(void)
HB_FUNC( TOKEN )
{
do_token1( DO_TOKEN1_TOKEN );
}
| token1.c | 577 |
HB_FUNC | NUMTOKEN(void)
HB_FUNC( NUMTOKEN )
{
do_token1( DO_TOKEN1_NUMTOKEN );
}
| token1.c | 613 |
HB_FUNC | TOKENLOWER(void)
HB_FUNC( TOKENLOWER )
{
do_token1( DO_TOKEN1_TOKENLOWER );
}
| token1.c | 679 |
HB_FUNC | TOKENUPPER(void)
HB_FUNC( TOKENUPPER )
{
do_token1( DO_TOKEN1_TOKENUPPER );
}
| token1.c | 746 |
HB_FUNC | TOKENSEP(void)
HB_FUNC( TOKENSEP )
{
char cRet;
if( ISLOG( 1 ) && hb_parl( 1 ) )
{
/* return the separator char BEHIND the last token */
if( siPostSeparator != -1 )
{
cRet = ( char ) siPostSeparator;
hb_retclen( &cRet, 1 );
}
else
hb_retc( NULL );
}
else
{
/* return the separator char BEFORE the last token */
if( siPreSeparator != -1 )
{
cRet = ( char ) siPreSeparator;
hb_retclen( &cRet, 1 );
}
else
hb_retc( NULL );
}
}
| token1.c | 792 |
token2.c |
Type | Function | Source | Line |
STATIC TOKEN_ENVIRONMENT | sTokEnvNew( void )
/* alloc new token environment */
/* -------------------------------------------------------------------- */
static TOKEN_ENVIRONMENT sTokEnvNew( void )
{
TOKEN_ENVIRONMENT env = ( TOKEN_ENVIRONMENT )
hb_xalloc( sizeof( TOKEN_POSITION ) * ( 2 + TOKEN_ENVIRONMENT_STEP ) );
if( env == NULL )
return NULL;
/* use the first element to store current length and use of token env */
env[0].sStartPos = 0; /* 0-based index to next free, unused element */
env[0].sEndPos = TOKEN_ENVIRONMENT_STEP; /* but there are 100 elements ready for use */
/* use second element to store actual index with tokennext() */
env[1].sStartPos = 0; /* 0-based index value that is to be used NEXT */
return env;
}
/* -------------------------------------------------------------------- */
/* add a tokenizing position to a token environment */
| token2.c | 84 |
STATIC INT | sTokEnvAddPos( TOKEN_ENVIRONMENT * pEnv, TOKEN_POSITION * pPos )
static int sTokEnvAddPos( TOKEN_ENVIRONMENT * pEnv, TOKEN_POSITION * pPos )
{
size_t index;
TOKEN_ENVIRONMENT env = *pEnv;
/* new memory needed ? */
if( env[0].sStartPos == env[0].sEndPos )
{
env = *pEnv = ( TOKEN_ENVIRONMENT )
hb_xrealloc( env, sizeof( TOKEN_POSITION ) *
( 2 + env[0].sEndPos + TOKEN_ENVIRONMENT_STEP ) );
if( env == NULL )
return 0;
env[0].sEndPos += TOKEN_ENVIRONMENT_STEP;
}
index = env[0].sStartPos + 2; /* +2 because of extra elements */
env[index].sStartPos = pPos->sStartPos;
env[index].sEndPos = pPos->sEndPos;
env[0].sStartPos++;
return 1;
}
/* -------------------------------------------------------------------- */
/* check to see if token pointer is at end of environment */
| token2.c | 108 |
STATIC INT | sTokEnvEnd( TOKEN_ENVIRONMENT env )
static int sTokEnvEnd( TOKEN_ENVIRONMENT env )
{
return env[1].sStartPos >= env[0].sStartPos;
}
/* -------------------------------------------------------------------- */
/* get size of token environment in memory */
| token2.c | 137 |
STATIC SIZE_T | sTokEnvGetSize( TOKEN_ENVIRONMENT env )
static size_t sTokEnvGetSize( TOKEN_ENVIRONMENT env )
{
return sizeof( TOKEN_POSITION ) * ( 2 + env[0].sEndPos );
}
/* -------------------------------------------------------------------- */
/* get position element pointed to by tokenizing pointer */
| token2.c | 146 |
STATIC TOKEN_POSITION | sTokEnvGetPos( TOKEN_ENVIRONMENT env )
static TOKEN_POSITION *sTokEnvGetPos( TOKEN_ENVIRONMENT env )
{
if( env[1].sStartPos >= env[0].sStartPos )
return NULL;
return env + 2 + ( env[1].sStartPos ); /* "+2" because of extra elements */
}
/* -------------------------------------------------------------------- */
/* get position element pointed to by given 0-based index */
| token2.c | 155 |
STATIC TOKEN_POSITION | sTokEnvGetPosIndex( TOKEN_ENVIRONMENT env, size_t index )
static TOKEN_POSITION *sTokEnvGetPosIndex( TOKEN_ENVIRONMENT env, size_t index )
{
if( index >= env[0].sStartPos )
return NULL;
return env + 2 + index; /* "+2" because of extra elements */
}
/* -------------------------------------------------------------------- */
/* increment tokenizing pointer by one */
| token2.c | 167 |
STATIC INT | sTokEnvIncPtr( TOKEN_ENVIRONMENT env )
static int sTokEnvIncPtr( TOKEN_ENVIRONMENT env )
{
if( env[1].sStartPos >= env[0].sStartPos )
return 0;
else
{
env[1].sStartPos++;
return 1;
}
}
/* -------------------------------------------------------------------- */
/* set tokenizing pointer to 0-based value */
| token2.c | 179 |
STATIC INT | sTokEnvSetPtr( TOKEN_ENVIRONMENT env, size_t sCnt )
static int sTokEnvSetPtr( TOKEN_ENVIRONMENT env, size_t sCnt )
{
if( sCnt >= env[0].sStartPos )
return 0;
else
{
env[1].sStartPos = sCnt;
return 1;
}
}
/* -------------------------------------------------------------------- */
/* decrement tokenizing pointer by one */
/* -------------------------------------------------------------------- */
/* sTokEnvDecPtr currently not used ! */
/* static int sTokEnvDecPtr( TOKEN_ENVIRONMENT env )
{
if( env[1].sStartPos <= 0 )
return 0;
else
{
env[1].sStartPos--;
return 1;
}
} */
/* -------------------------------------------------------------------- */
/* get value of tokenizing pointer */
| token2.c | 194 |
STATIC SIZE_T | sTokEnvGetPtr( TOKEN_ENVIRONMENT env )
static size_t sTokEnvGetPtr( TOKEN_ENVIRONMENT env )
{
return env[1].sStartPos;
}
/* -------------------------------------------------------------------- */
/* get token count */
| token2.c | 225 |
STATIC SIZE_T | sTokEnvGetCnt( TOKEN_ENVIRONMENT env )
static size_t sTokEnvGetCnt( TOKEN_ENVIRONMENT env )
{
return env[0].sStartPos;
}
/* -------------------------------------------------------------------- */
/* free token environment */
| token2.c | 234 |
STATIC VOID | sTokEnvDel( TOKEN_ENVIRONMENT env )
static void sTokEnvDel( TOKEN_ENVIRONMENT env )
{
hb_xfree( env );
}
/* ==================================================================== */
/* HARBOUR functions */
/* ==================================================================== */
/* static data */
static const char *spcSeparatorStr =
"\x00" "\x09" "\x0A" "\x0C" "\x1A" "\x20" "\x8A" "\x8C" ",.;:!\?/\\<>()#&%+-*";
static const size_t ssSeparatorStrLen = 26;
/* TODO: make thread safe */
static TOKEN_ENVIRONMENT s_sTokenEnvironment = NULL;
static BOOL s_fInit = FALSE;
| token2.c | 243 |
STATIC VOID | sTokExit( void * cargo )
static void sTokExit( void * cargo )
{
HB_SYMBOL_UNUSED( cargo );
if( s_sTokenEnvironment )
{
sTokEnvDel( s_sTokenEnvironment );
s_sTokenEnvironment = NULL;
}
}
| token2.c | 261 |
STATIC VOID | sTokSet( TOKEN_ENVIRONMENT env )
static void sTokSet( TOKEN_ENVIRONMENT env )
{
if( !s_fInit && env )
{
hb_vmAtExit( sTokExit, NULL );
s_fInit = TRUE;
}
if( s_sTokenEnvironment )
sTokEnvDel( s_sTokenEnvironment );
s_sTokenEnvironment = env;
}
| token2.c | 272 |
HB_FUNC | TOKENINIT(void)
HB_FUNC( TOKENINIT )
{
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
char *pcSeparatorStr;
size_t sSeparatorStrLen;
ULONG ulSkipCnt, ulSkip;
char *pcSubStr, *pc;
size_t sSubStrLen;
TOKEN_ENVIRONMENT sTokenEnvironment;
TOKEN_POSITION sTokenPosition;
/* separator string */
sSeparatorStrLen = hb_parclen( 2 );
if( sSeparatorStrLen > 0 )
pcSeparatorStr = hb_parc( 2 );
else
{
pcSeparatorStr = ( char * ) spcSeparatorStr;
sSeparatorStrLen = ssSeparatorStrLen;
}
/* skip width */
if( ISNUM( 3 ) )
ulSkip = hb_parnl( 3 );
else
ulSkip = ULONG_MAX;
if( ulSkip == 0 )
ulSkip = ULONG_MAX;
/* allocate new token environment */
if( ( sTokenEnvironment = sTokEnvNew() ) == NULL )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_MEM, CT_ERROR_TOKENINIT,
NULL, "TOKENINIT", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
hb_retl( 0 );
return;
}
pcSubStr = pcString;
sSubStrLen = sStrLen;
/* scan start condition */
pc = pcSubStr - 1;
while( 1 )
{
size_t sMatchedPos = sSeparatorStrLen;
/* ulSkip */
ulSkipCnt = 0;
do
{
sSubStrLen -= ( pc - pcSubStr ) + 1;
pcSubStr = pc + 1;
pc = ct_at_charset_forward( pcSubStr, sSubStrLen, pcSeparatorStr,
sSeparatorStrLen, &sMatchedPos );
ulSkipCnt++;
}
while( ulSkipCnt < ulSkip && pc == pcSubStr );
if( sSubStrLen == 0 )
break;
sTokenPosition.sStartPos = pcSubStr - pcString;
if( pc == NULL )
sTokenPosition.sEndPos = pcSubStr - pcString + sSubStrLen;
else
sTokenPosition.sEndPos = pc - pcString;
if( !sTokEnvAddPos( &sTokenEnvironment, &sTokenPosition ) )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_MEM, CT_ERROR_TOKENINIT,
NULL, "TOKENINIT", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
sTokEnvDel( sTokenEnvironment );
hb_retl( 0 );
return;
}
if( pc == NULL )
break;
} /* while( 1 ); */
/* save token environment to 4th parameter OR to the static */
if( ISBYREF( 4 ) )
{
hb_storclen( ( char * ) sTokenEnvironment, sTokEnvGetSize( sTokenEnvironment ), 4 );
sTokEnvDel( sTokenEnvironment );
}
else
{
sTokSet( sTokenEnvironment );
}
hb_retl( 1 );
}
else /* ISCHAR( 1 ) */
{
/* if there is a token environment stored in either the 4th parameter or
in the static variable -> rewind to first token */
TOKEN_ENVIRONMENT sTokenEnvironment;
if( ISCHAR( 4 ) && ISBYREF( 4 ) )
sTokenEnvironment = ( TOKEN_ENVIRONMENT ) hb_parc( 4 );
else
sTokenEnvironment = s_sTokenEnvironment;
if( sTokenEnvironment != NULL )
{
/* rewind to first token */
hb_retl( sTokEnvSetPtr( sTokenEnvironment, 0 ) );
if( ISCHAR( 4 ) && ISBYREF( 4 ) )
hb_storclen( ( char * ) sTokenEnvironment, sTokEnvGetSize( sTokenEnvironment ), 4 );
}
else
{
/* nothing to rewind -> return .f. */
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TOKENINIT, NULL, "TOKENINIT", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retl( 0 );
}
}
}
| token2.c | 370 |
HB_FUNC | TOKENNEXT(void)
HB_FUNC( TOKENNEXT )
{
if( ISCHAR( 1 ) )
{
char *pcString = hb_parc( 1 );
size_t sStrLen = ( size_t ) hb_parclen( 1 );
TOKEN_ENVIRONMENT sTokenEnvironment;
TOKEN_POSITION *psTokenPosition;
/* token environment by parameter ... */
if( ISCHAR( 3 ) && ISBYREF( 3 ) )
{
size_t sStrLen3 = ( size_t ) hb_parclen( 3 );
if( sStrLen3 < sizeof( TOKEN_POSITION ) * 2 )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENNEXT,
NULL, "TOKENNEXT", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
return;
}
sTokenEnvironment = ( TOKEN_ENVIRONMENT ) hb_xgrab( sStrLen3 );
hb_xmemcpy( ( char * ) sTokenEnvironment, hb_parc( 3 ), sStrLen3 );
}
else
{
/* ... or static ? */
if( s_sTokenEnvironment == NULL )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENNEXT,
NULL, "TOKENNEXT", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
return;
}
sTokenEnvironment = s_sTokenEnvironment;
}
/* nth token or next token ? */
if( ISNUM( 2 ) )
{
psTokenPosition = sTokEnvGetPosIndex( sTokenEnvironment, hb_parnl( 2 ) - 1 );
/* no increment here */
}
else
{
psTokenPosition = sTokEnvGetPos( sTokenEnvironment );
/* increment counter */
sTokEnvIncPtr( sTokenEnvironment );
}
if( ( psTokenPosition == NULL ) || ( sStrLen <= psTokenPosition->sStartPos ) )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENNEXT, NULL,
"TOKENNEXT", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
if( ISCHAR( 3 ) && ISBYREF( 3 ) )
{
hb_storclen( ( char * ) sTokenEnvironment, sTokEnvGetSize( sTokenEnvironment ), 3 );
hb_xfree( ( char * ) sTokenEnvironment );
}
hb_retc( NULL );
return;
}
if( sStrLen < psTokenPosition->sEndPos )
hb_retclen( pcString + psTokenPosition->sStartPos,
sStrLen - ( psTokenPosition->sStartPos ) );
else
hb_retclen( pcString + psTokenPosition->sStartPos,
( psTokenPosition->sEndPos ) - ( psTokenPosition->sStartPos ) );
if( ISCHAR( 3 ) && ISBYREF( 3 ) )
{
hb_storclen( ( char * ) sTokenEnvironment, sTokEnvGetSize( sTokenEnvironment ), 3 );
hb_xfree( ( char * ) sTokenEnvironment );
}
}
else
{
/* no string given, no token returns */
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TOKENNEXT, NULL, "TOKENNEXT", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| token2.c | 576 |
HB_FUNC | TOKENNUM(void)
HB_FUNC( TOKENNUM )
{
TOKEN_ENVIRONMENT sTokenEnvironment;
if( ISCHAR( 1 ) && ISBYREF( 1 ) )
sTokenEnvironment = ( TOKEN_ENVIRONMENT ) hb_parc( 1 );
else
sTokenEnvironment = s_sTokenEnvironment;
if( ( void * ) sTokenEnvironment != NULL )
hb_retnl( sTokEnvGetCnt( sTokenEnvironment ) );
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TOKENNUM, NULL, "TOKENNUM", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retni( 0 );
}
}
| token2.c | 727 |
HB_FUNC | TOKENEND(void)
HB_FUNC( TOKENEND )
{
TOKEN_ENVIRONMENT sTokenEnvironment;
if( ISCHAR( 1 ) && ISBYREF( 1 ) )
sTokenEnvironment = ( TOKEN_ENVIRONMENT ) hb_parc( 1 );
else
sTokenEnvironment = s_sTokenEnvironment;
if( ( void * ) sTokenEnvironment != NULL )
hb_retl( sTokEnvEnd( sTokenEnvironment ) );
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TOKENEND, NULL, "TOKENEND", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
/* it is CTIII behaviour to return .T. if there's no string TOKENINIT'ed */
hb_retl( 1 );
}
}
| token2.c | 800 |
HB_FUNC | TOKENEXIT(void)
HB_FUNC( TOKENEXIT )
{
if( s_sTokenEnvironment != NULL )
{
sTokExit( NULL );
hb_retl( 1 );
}
else
hb_retl( 0 );
}
| token2.c | 869 |
HB_FUNC | TOKENAT(void)
HB_FUNC( TOKENAT )
{
int iSeparatorPos = 0;
size_t sCurrentIndex;
TOKEN_ENVIRONMENT sTokenEnvironment;
TOKEN_POSITION *psTokenPosition;
if( ISLOG( 1 ) )
iSeparatorPos = hb_parl( 1 );
if( ISCHAR( 3 ) && ISBYREF( 3 ) )
sTokenEnvironment = ( TOKEN_ENVIRONMENT ) hb_parc( 3 );
else
sTokenEnvironment = s_sTokenEnvironment;
if( ( void * ) sTokenEnvironment == NULL )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENAT,
NULL, "TOKENAT", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( 0 );
return;
}
if( ISNUM( 2 ) )
sCurrentIndex = hb_parnl( 2 ) - 1;
else
sCurrentIndex = sTokEnvGetPtr( sTokenEnvironment );
psTokenPosition = sTokEnvGetPosIndex( sTokenEnvironment, sCurrentIndex );
if( psTokenPosition == NULL )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_ARG, CT_ERROR_TOKENAT, NULL,
"TOKENAT", 0, EF_CANDEFAULT, HB_ERR_ARGS_BASEPARAMS );
}
hb_retni( 0 );
return;
}
if( iSeparatorPos )
hb_retnl( psTokenPosition->sEndPos + 1 );
else
hb_retnl( psTokenPosition->sStartPos + 1 );
}
| token2.c | 937 |
HB_FUNC | SAVETOKEN(void)
HB_FUNC( SAVETOKEN )
{
if( s_sTokenEnvironment != NULL )
hb_retclen( ( char * ) s_sTokenEnvironment, sTokEnvGetSize( s_sTokenEnvironment ) );
else
hb_retc( NULL );
}
| token2.c | 1023 |
HB_FUNC | RESTTOKEN(void)
HB_FUNC( RESTTOKEN )
{
TOKEN_ENVIRONMENT sTokenEnvironment = NULL;
size_t sStrLen = 1;
if( ISCHAR( 1 ) )
{
sStrLen = ( size_t ) hb_parclen( 1 );
if( sStrLen >= sizeof( TOKEN_POSITION ) )
{
TOKEN_ENVIRONMENT env = ( TOKEN_ENVIRONMENT ) hb_parc( 1 );
if( sTokEnvGetSize( env ) == sStrLen )
{
/* alloc memory for new environment */
sTokenEnvironment = ( TOKEN_ENVIRONMENT ) hb_xalloc( sStrLen );
if( sTokenEnvironment == NULL )
{
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
ct_error( ( USHORT ) iArgErrorMode, EG_MEM, CT_ERROR_RESTTOKEN,
NULL, "RESTTOKEN", 0, EF_CANDEFAULT,
HB_ERR_ARGS_BASEPARAMS );
}
hb_retc( NULL );
return;
}
hb_xmemcpy( sTokenEnvironment, env, sStrLen );
}
}
}
if( sTokenEnvironment != NULL || sStrLen == 0 )
{
/* return current environment, then delete it */
if( s_sTokenEnvironment != NULL )
hb_retclen( ( char * ) s_sTokenEnvironment, sTokEnvGetSize( s_sTokenEnvironment ) );
else
hb_retc( NULL );
sTokSet( sTokenEnvironment );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_RESTTOKEN, NULL, "RESTTOKEN", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retc( NULL );
}
}
| token2.c | 1065 |
trig.c |
Type | Function | Source | Line |
HB_FUNC | PI(void)
HB_FUNC( PI )
{
hb_retnd( CT_PI );
}
| trig.c | 111 |
HB_FUNC | SIN(void)
HB_FUNC( SIN )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = sin( dArg );
if( hb_mathGetError( &hb_exc, "SIN", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
hb_retndlen( HUGE_VAL, -1, -1 );
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_SIN, NULL, "SIN", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 157 |
HB_FUNC | COS(void)
HB_FUNC( COS )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = cos( dArg );
if( hb_mathGetError( &hb_exc, "COS", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
hb_retndlen( HUGE_VAL, -1, -1 );
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_COS, NULL, "COS", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 235 |
HB_FUNC | TAN(void)
HB_FUNC( TAN )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = tan( dArg );
if( hb_mathGetError( &hb_exc, "TAN", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
hb_retndlen( HUGE_VAL, -1, -1 );
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TAN, NULL, "TAN", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 313 |
HB_FUNC | COT(void)
HB_FUNC( COT )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = tan( dArg );
if( hb_mathGetError( &hb_exc, "TAN", dArg, 0.0, dResult ) )
{
dResult = hb_exc.handled ? hb_exc.retval : 0.0;
}
dResult = dResult ? 1 / dResult : HUGE_VAL;
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_COT, NULL, "COT", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 389 |
HB_FUNC | ASIN(void)
HB_FUNC( ASIN )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = asin( dArg );
if( hb_mathGetError( &hb_exc, "ASIN", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
hb_retndlen( HUGE_VAL, -1, -1 );
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_ASIN, NULL, "ASIN", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 465 |
HB_FUNC | ACOS(void)
HB_FUNC( ACOS )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = acos( dArg );
if( hb_mathGetError( &hb_exc, "ACOS", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
hb_retndlen( HUGE_VAL, -1, -1 );
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_ACOS, NULL, "ACOS", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 545 |
HB_FUNC | ATAN(void)
HB_FUNC( ATAN )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = atan( dArg );
if( hb_mathGetError( &hb_exc, "ATAN", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
{
/* atan normally don't error, but it's save to return PI()/2
or -PI()/2, respectively, as these
are the boundary result values */
if( dArg < 0.0 )
hb_retnd( -CT_PI / 2.0 );
else
hb_retnd( CT_PI / 2.0 );
}
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_ATAN, NULL, "ATAN", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 621 |
HB_FUNC | ATN2(void)
HB_FUNC( ATN2 )
{
if( ISNUM( 1 ) && ISNUM( 2 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dY = hb_parnd( 1 );
double dX = hb_parnd( 2 );
double dResult;
hb_mathResetError( &hb_exc );
dResult = atan2( dY, dX );
if( hb_mathGetError( &hb_exc, "ATAN2", dY, dX, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
{
/* DOMAIN error: both arguments to atan2 have been 0 */
/* CTIII behaves very strange here: atn2 (0.0, 0.0) == -PI
atn2 (0.0, -0.0) == 0.0
atn2 (-0.0, 0.0) == -PI
atn2 (-0.0, -0.0) == -2*PI */
if( dX >= 0.0 )
hb_retnd( -CT_PI );
else if( dY < 0.0 )
hb_retnd( -2.0 * CT_PI );
else
hb_retnd( 0.0 );
}
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_ATN2, NULL, "ATN2", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 712 |
HB_FUNC | SINH(void)
HB_FUNC( SINH )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = sinh( dArg );
if( hb_mathGetError( &hb_exc, "SINH", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
{
/* OVERFLOW error: we have no CTIII behaviour to follow,
so return +INF or -INF, respectively */
if( dArg < 0.0 )
hb_retndlen( -HUGE_VAL, -1, -1 );
else
hb_retndlen( HUGE_VAL, -1, -1 );
}
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_SINH, NULL, "SINH", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 803 |
HB_FUNC | COSH(void)
HB_FUNC( COSH )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = cosh( dArg );
if( hb_mathGetError( &hb_exc, "COSH", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
/* OVERFLOW error: we have no CTIII behaviour to follow,
so return +INF */
hb_retndlen( HUGE_VAL, -1, -1 );
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_COSH, NULL, "COSH", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 887 |
HB_FUNC | TANH(void)
HB_FUNC( TANH )
{
if( ISNUM( 1 ) )
{
HB_MATH_EXCEPTION hb_exc;
double dResult, dArg = hb_parnd( 1 );
hb_mathResetError( &hb_exc );
dResult = tanh( dArg );
if( hb_mathGetError( &hb_exc, "TANH", dArg, 0.0, dResult ) )
{
if( hb_exc.handled )
hb_retndlen( hb_exc.retval, hb_exc.retvalwidth, hb_exc.retvaldec );
else
{
/* normally, tanh() doesn't give errors, but let's return -1 or +1,
respectively, as these are the boundary result values */
if( dArg < 0.0 )
hb_retnd( -1.0 );
else
hb_retnd( 1.0 );
}
}
else
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_TANH, NULL, "TANH", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 962 |
HB_FUNC | RTOD(void)
HB_FUNC( RTOD )
{
if( ISNUM( 1 ) )
{
double dInput = hb_parnd( 1 );
double dResult = ( 180.0 / CT_PI ) * dInput;
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_RTOD, NULL, "RTOD", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 1043 |
HB_FUNC | DTOR(void)
HB_FUNC( DTOR )
{
if( ISNUM( 1 ) )
{
double dInput = hb_parnd( 1 );
double dResult = ( CT_PI / 180.0 ) * dInput;
hb_retnd( dResult );
}
else
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_DTOR, NULL, "DTOR", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else
hb_retnd( 0.0 );
}
}
| trig.c | 1106 |
video.c |
Type | Function | Source | Line |
HB_FUNC | CHARPIX(void)
HB_FUNC( CHARPIX )
{
# ifdef __DJGPP__
hb_retni( _farpeekw( _dos_ds, 0x485 ) );
# endif
}
| video.c | 99 |
HB_FUNC | VGAPALETTE(void)
HB_FUNC( VGAPALETTE )
{
char *color_string;
char red, green, blue;
char attr = 0;
if( hb_pcount() < 4 )
{
/* Resetting palette registers to default values is not supported yet */
hb_retl( FALSE );
return;
}
if( ISNUM( 1 ) && hb_parni( 1 ) < 16 )
{
attr = hb_parni( 1 );
}
else if( ISCHAR( 1 ) )
{
char *s;
color_string = hb_parcx( 1 );
for( s = color_string; *s; s++ )
{
switch ( *s )
{
case 'N':
case 'n':
attr |= 0;
break;
case 'B':
case 'b':
attr |= 1;
break;
case 'G':
case 'g':
attr |= 2;
break;
case 'R':
case 'r':
attr |= 4;
break;
case 'W':
case 'w':
attr |= 7;
break;
case '+':
attr |= 8;
break;
case 'U':
case 'u':
case 'I':
case 'i':
case 'X':
case 'x':
/* these seem to be used only in mono */
break;
default:
hb_retl( FALSE );
return;
}
}
}
else
{
/* An invalid argument */
hb_retl( FALSE );
return;
}
red = hb_parni( 2 );
green = hb_parni( 3 );
blue = hb_parni( 4 );
# ifdef __DJGPP__
{
__dpmi_regs r;
int iflag;
/* Get palette register for this attribute to BH using BIOS -
* I couldn't manage to get it through ports */
r.x.ax = 0x1007;
r.h.bl = attr;
__dpmi_int( 0x10, &r );
iflag = __dpmi_get_and_disable_virtual_interrupt_state();
/* Wait for vertical retrace (for old VGA cards) */
while( inportb( 0x3DA ) & 8 ) ;
while( !( inportb( 0x3DA ) & 8 ) ) ;
outportb( 0x3C8, r.h.bh );
outportb( 0x3C9, red );
outportb( 0x3C9, green );
outportb( 0x3C9, blue );
if( iflag )
__dpmi_get_and_enable_virtual_interrupt_state();
}
hb_retl( TRUE );
# else
hb_retl( FALSE );
# endif
}
| video.c | 144 |
HB_FUNC | VIDEOTYPE(void)
HB_FUNC( VIDEOTYPE )
{
# if defined( __DJGPP__ )
__dpmi_regs r;
r.h.ah = 0x12; /* Alternate Select */
r.h.bl = 0x10; /* Get EGA info */
__dpmi_int( 0x10, &r );
if( r.h.bl == 0x10 )
{
/* CGA/HGC/MDA */
hb_retni( VCARD_MONOCHROME );
}
else
{
/* EGA/VGA */
r.x.ax = 0x1A00;
__dpmi_int( 0x10, &r );
if( r.h.al == 0x1A )
hb_retni( VCARD_VGA );
else
hb_retni( VCARD_EGA );
}
# endif
}
| video.c | 277 |
HB_FUNC | SETFONT(void)
HB_FUNC( SETFONT )
{
char *font = hb_parcx( 1 );
int len = hb_parclen( 1 );
int area = hb_parni( 2 );
int offset = 0;
int count = 256;
int height = 16;
if( !area )
area = 1;
if( ISNUM( 3 ) )
offset = hb_parni( 3 );
if( ISNUM( 4 ) )
count = hb_parni( 4 );
if( ISLOG( 3 ) )
if( hb_parl( 3 ) && count != 0 )
height = len / count;
# ifdef __DJGPP__
{
__dpmi_regs r;
r.x.ax = 0x1110; /* Load user-defined text-mode display font */
r.h.bl = area - 1;
r.h.bh = height;
r.x.cx = count;
r.x.dx = offset;
r.x.es = __tb >> 4;
r.x.bp = __tb & 0xF;
dosmemput( font, len, __tb );
__dpmi_int( 0x10, &r );
}
# endif
hb_retni( 0 );
}
| video.c | 338 |
wordrepl.c |
Type | Function | Source | Line |
HB_FUNC | WORDREPL(void)
HB_FUNC( WORDREPL )
{
int iNoRet;
int iMultiPass;
size_t sSearchLen, sReplaceLen;
/* suppressing return value ? */
iNoRet = ct_getref() && ISBYREF( 2 );
iMultiPass = ct_getatmupa();
/* param check */
if( ( sSearchLen = ( size_t ) hb_parclen( 1 ) ) / 2 > 0 && ISCHAR( 2 ) &&
( sReplaceLen = ( size_t ) hb_parclen( 3 ) ) / 2 > 0 )
{
/* get parameters */
char *pcSearch = hb_parc( 1 );
char *pcString = hb_parc( 2 );
size_t sStrLen = ( size_t ) hb_parclen( 2 );
char *pcReplace = hb_parc( 3 );
int iMode;
char *pcRet;
size_t sIndex;
if( ISLOG( 4 ) )
iMode = hb_parl( 4 );
else
iMode = 0;
pcRet = ( char * ) hb_xgrab( sStrLen + 1 );
hb_xmemcpy( pcRet, pcString, sStrLen );
for( sIndex = 0; sIndex < ( sSearchLen & 0xFFFFFFFE ); sIndex += 2 )
{
size_t sMatchStrLen;
char *pc;
size_t sReplIndex = sIndex;
if( sReplIndex > ( sReplaceLen & 0xFFFFFFFE ) )
{
sReplIndex = ( sReplaceLen & 0xFFFFFFFE );
}
pc = pcString;
while( ( pc = ct_at_exact_forward( pc, sStrLen - ( pc - pcString ),
pcSearch + sIndex, 2, &sMatchStrLen ) ) != NULL )
{
if( iMode )
{
/* always replace */
*( pcRet + ( pc - pcString ) ) = *( pcReplace + sReplIndex );
*( pcRet + ( pc - pcString ) + 1 ) = *( pcReplace + sReplIndex + 1 );
if( iMultiPass )
pc++;
else
pc += 2;
}
else
{
/* replace only if pc is an even position */
if( ( ( pc - pcString ) % 2 ) == 0 )
{
*( pcRet + ( pc - pcString ) ) = *( pcReplace + sReplIndex );
*( pcRet + ( pc - pcString ) + 1 ) = *( pcReplace + sReplIndex + 1 );
/* parse pcString in steps of two characters */
pc += 2;
}
else
{
/* we are on an odd position, so add only 1 to pc */
pc++;
}
}
}
}
/* return string */
if( ISBYREF( 2 ) )
{
hb_storclen( pcRet, sStrLen, 2 );
}
if( iNoRet )
{
hb_retl( 0 );
hb_xfree( pcRet );
}
else
{
hb_retclen_buffer( pcRet, sStrLen );
}
}
else /* ( sSearchLen = ( size_t ) hb_parclen( 1 ) ) / 2 > 0 && ISCHAR( 2 ) &&
( sReplaceLen = ( size_t ) hb_parclen( 3 ) ) / 2 > 0 */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_WORDREPL, NULL, "WORDREPL", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( iNoRet )
hb_retl( 0 );
else if( ISCHAR( 2 ) )
hb_retclen( hb_parc( 2 ), hb_parclen( 2 ) );
else
hb_retc( NULL );
}
}
| wordrepl.c | 123 |
wordtoch.c |
Type | Function | Source | Line |
HB_FUNC | WORDTOCHAR(void)
HB_FUNC( WORDTOCHAR )
{
int iMultiPass;
size_t sSearchLen, sStrLen, sReplaceLen;
iMultiPass = ct_getatmupa();
/* param check */
if( ( sSearchLen = ( size_t ) hb_parclen( 1 ) ) / 2 > 0 &&
( sStrLen = ( size_t ) hb_parclen( 2 ) ) / 2 > 0 &&
( sReplaceLen = ( size_t ) hb_parclen( 3 ) ) > 0 )
{
/* get parameters */
char *pcSearch = ( char * ) hb_parc( 1 );
char *pcString = ( char * ) hb_parc( 2 );
char *pcReplace = ( char * ) hb_parc( 3 );
char *pcRet;
size_t sRetIndex, sIndex;
int iNoReplace;
pcRet = ( char * ) hb_xgrab( sStrLen );
sRetIndex = 0;
sIndex = 0;
iNoReplace = 0;
*pcRet = *pcString; /* copy first char */
do
{
size_t sMatchStrLen;
char *pc;
size_t sReplIndex;
*( pcRet + sRetIndex + 1 ) = *( pcString + sIndex + 1 );
if( !iNoReplace &&
( ( pc = ct_at_exact_forward( pcSearch, sSearchLen,
pcRet + sRetIndex, 2,
&sMatchStrLen ) ) != NULL ) &&
( ( ( sReplIndex = ( pc - pcSearch ) ) & 1 ) != 1 ) )
{
sReplIndex /= 2;
if( sReplIndex >= sReplaceLen )
sReplIndex = sReplaceLen - 1;
*( pcRet + sRetIndex ) = *( pcReplace + sReplIndex );
if( !iMultiPass )
iNoReplace = 1; /* just copy next char without searching & replacing */
}
else
{
iNoReplace = 0;
sRetIndex++;
}
sIndex++;
}
while( sIndex < sStrLen - 1 );
/* return string */
hb_retclen( pcRet, sRetIndex + 1 );
hb_xfree( pcRet );
}
else /* ( sSearchLen = ( size_t ) hb_parclen( 1 ) ) / 2 > 0 &&
( sStrLen = ( size_t ) hb_parclen( 2 ) ) / 2 > 0 &&
( sReplaceLen = ( size_t ) hb_parclen( 3 ) ) > 0 */
{
PHB_ITEM pSubst = NULL;
int iArgErrorMode = ct_getargerrormode();
if( iArgErrorMode != CT_ARGERR_IGNORE )
{
pSubst = ct_error_subst( ( USHORT ) iArgErrorMode, EG_ARG,
CT_ERROR_WORDTOCHAR, NULL, "WORDTOCHAR", 0,
EF_CANSUBSTITUTE, HB_ERR_ARGS_BASEPARAMS );
}
if( pSubst != NULL )
hb_itemReturnRelease( pSubst );
else if( ISCHAR( 2 ) )
hb_retclen( hb_parc( 2 ), hb_parclen( 2 ) );
else
hb_retc( NULL );
}
}
| wordtoch.c | 88 |
blank.prg |
Type | Function | Source | Line |
FUNCTION | BLANK( xItem, xMode )
FUNCTION BLANK( xItem, xMode )
LOCAL cType := ValType( xItem )
LOCAL xRet
SWITCH cType
CASE "D"
xRet := CTOD( "" )
EXIT
CASE "L"
xRet :=.F.
EXIT
CASE "N"
xRet := 0
EXIT
CASE "C"
CASE "M"
xRet := xItem := IIF( ISLOGICAL( xMode ) .and. xMode, ;
Space( Len( xItem ) ), "" )
EXIT
CASE "A"
xRet := {}
EXIT
CASE "H"
xRet := {=>}
EXIT
OTHERWISE
xRet:=.F.
ENDSWITCH
RETURN xRet
| blank.prg | 57 |
ct.prg |
Type | Function | Source | Line |
FUNCTION | CTINIT()
function CTINIT()
if !sbInitialized
sbInitialized := ctcinit()
endif
return sbInitialized
| ct.prg | 92 |
INIT FUNCTION | _CTINIT()
init function _CTINIT()
if !sbInitialized
sbInitialized := ctcinit()
endif
return sbInitialized
| ct.prg | 100 |
FUNCTION | CTEXIT()
function CTEXIT()
if sbInitialized
ctcexit()
sbInitialized := .F.
endif
return nil
| ct.prg | 142 |
EXIT FUNCTION | _CTEXIT()
exit function _CTEXIT()
if sbInitialized
ctcexit()
sbInitialized := .F.
endif
return nil
| ct.prg | 151 |
ctmisc.prg |
Type | Function | Source | Line |
FUNCTION | CENTER( c, n, p, lMode )
FUNCTION CENTER( c, n, p, lMode )
LOCAL cRet
DEFAULT n TO MaxCol() + 1 - Col()*2
DEFAULT c TO ""
DEFAULT lMode TO .F.
cRet := PadC( AllTrim( c ), n, p )
RETURN if(lMode, cRet, RTrim( cRet ) )
| ctmisc.prg | 59 |
FUNCTION | CSETCURS( l )
FUNCTION CSETCURS( l )
IF ! ISLOGICAL( l )
RETURN SetCursor() != SC_NONE
ENDIF
RETURN SetCursor( iif( l, SC_NORMAL, SC_NONE ) ) != SC_NONE
| ctmisc.prg | 67 |
FUNCTION | CSETKEY( n )
FUNCTION CSETKEY( n )
RETURN SetKey( n )
| ctmisc.prg | 75 |
FUNCTION | CSETCENT( nCentury )
FUNCTION CSETCENT( nCentury )
if nCentury == NIL
RETURN __SETCENTURY()
else
RETURN __SETCENTURY( nCentury )
endif
RETURN NIL
| ctmisc.prg | 78 |
FUNCTION | LTOC( l )
FUNCTION LTOC( l )
RETURN iif( l, "T", "F" )
| ctmisc.prg | 86 |
FUNCTION | DOSPARAM
FUNCTION DOSPARAM
LOCAL cRet := ""
LOCAL nCount := HB_ARGC(), i
FOR i := 1 TO nCount
cRet += if(i==1, "", " ") + HB_ARGV( i )
NEXT
RETURN cRet
| ctmisc.prg | 89 |
FUNCTION | EXENAME()
FUNCTION EXENAME()
RETURN HB_ARGV( 0 )
| ctmisc.prg | 98 |
ctrand.prg |
Type | Function | Source | Line |
FUNCTION | Random( lMode )
FUNCTION Random( lMode )
RETURN IIF( VALTYPE( lMode ) == "L" .AND. lMode, ;
HB_RandomInt( -32768, 32767 ), HB_RandomInt( 0, 65535 ) )
| ctrand.prg | 54 |
FUNCTION | Rand( nStart )
FUNCTION Rand( nStart )
IF nStart != NIL
HB_RandomSeed( nStart )
ENDIF
RETURN HB_Random()
| ctrand.prg | 58 |
cttime.prg |
Type | Function | Source | Line |
FUNCTION | TIMETOSEC( cTime )
function TIMETOSEC( cTime )
local nSec := 0, nLen, i, aLim, aMod, nInd, n
if cTime == NIL
nSec := seconds()
elseif valtype( cTime ) == "C"
nLen := len( cTime )
if ( nLen + 1 ) % 3 == 0 .and. nLen <= 11
nInd := 1
aLim := { 24, 60, 60, 100 }
aMod := { 3600, 60, 1, 1/100 }
for i := 1 to nLen step 3
if isdigit( substr( cTime, i, 1 ) ) .and. ;
isdigit( substr( cTime, i + 1, 1 ) ) .and. ;
( i == nLen - 1 .or. substr( cTime, i + 2, 1 ) == ":" ) .and. ;
( n := val( substr( cTime, i, 2 ) ) ) < aLim[ nInd ]
nSec += n * aMod[ nInd ]
else
nSec := 0
exit
endif
++nInd
next
endif
endif
return round( nSec, 2) /* round FL val to be sure that you can compare it */
| cttime.prg | 54 |
FUNCTION | SECTOTIME( nSec, lHundr )
function SECTOTIME( nSec, lHundr )
local i, h, n
n := iif( !valtype( nSec ) == "N", seconds(), nSec )
if valtype( lHundr ) == "L" .and. lHundr
h := ":" + strzero( ( nSec * 100 ) % 100, 2 )
else
h := ""
endif
n := int( n % 86400 )
for i := 1 to 3
h := strzero( n % 60, 2 ) + iif( len( h ) == 0, "", ":") + h
n := int( n / 60 )
next
return h
| cttime.prg | 81 |
FUNCTION | MILLISEC( nDelay )
function MILLISEC( nDelay )
HB_IDLESLEEP( nDelay / 1000 )
return ""
| cttime.prg | 97 |
fcopy.prg |
Type | Function | Source | Line |
FUNCTION | FILECOPY( cSource, cDest, lMode )
FUNCTION FILECOPY( cSource, cDest, lMode )
LOCAL hDstFile
LOCAL cBuffer := SPACE( F_BLOCK )
LOCAL lDone := .F.
LOCAL nSrcBytes, nDstBytes, nTotBytes := 0
IF !ISLOGICAL( lMode )
lMode := .F.
ENDIF
IF s_hSrcFile != -1
FCLOSE( s_hSrcFile )
ENDIF
s_hSrcFile := FOPEN( cSource, FO_READ )
IF s_hSrcFile != -1
hDstFile := FCREATE( cDest )
IF hDstFile != -1
DO WHILE !lDone
nSrcBytes := FREAD( s_hSrcFile, @cBuffer, F_BLOCK )
IF nSrcBytes == 0
lDone := .T.
EXIT
ENDIF
nDstBytes := FWRITE( hDstFile, cBuffer, nSrcBytes )
IF nDstBytes > 0
nTotBytes += nDstBytes
ENDIF
IF nDstBytes < nSrcBytes
EXIT
ENDIF
ENDDO
FCLOSE( hDstFile )
IF lDone .OR. !lMode
FCLOSE( s_hSrcFile )
s_hSrcFile := -1
ENDIF
s_fileDate := FILEDATE( cSource )
s_fileTime := FILETIME( cSource )
IF s_lSetDaTi
SETFDATI( cDest, s_fileDate, s_fileTime )
ENDIF
ELSE
FCLOSE( s_hSrcFile )
s_hSrcFile := -1
ENDIF
ENDIF
RETURN nTotBytes
| fcopy.prg | 83 |
FUNCTION | FILECOPEN()
FUNCTION FILECOPEN()
RETURN s_hSrcFile != -1
| fcopy.prg | 131 |
FUNCTION | FILECDATI( lNewMode )
FUNCTION FILECDATI( lNewMode )
LOCAL lOldMode := s_lSetDaTi
IF ISLOGICAL( lNewMode )
s_lSetDaTi := lNewMode
ENDIF
RETURN lOldMode
| fcopy.prg | 135 |
FUNCTION | FILECCONT( cDest )
FUNCTION FILECCONT( cDest )
LOCAL hDstFile
LOCAL cBuffer := SPACE( F_BLOCK )
LOCAL lDone := .F.
LOCAL nSrcBytes, nDstBytes, nTotBytes := 0
IF s_hSrcFile != -1
hDstFile := FCREATE( cDest )
IF hDstFile != -1
DO WHILE !lDone
nSrcBytes := FREAD( s_hSrcFile, @cBuffer, F_BLOCK )
IF nSrcBytes == 0
lDone := 0
EXIT
ENDIF
nDstBytes := FWRITE( hDstFile, cBuffer, nSrcBytes )
IF nDstBytes > 0
nTotBytes += nDstBytes
ENDIF
IF nDstBytes < nSrcBytes
EXIT
ENDIF
ENDDO
FCLOSE( hDstFile )
IF lDone
FCLOSE( s_hSrcFile )
s_hSrcFile := -1
ENDIF
IF s_lSetDaTi
SETFDATI( cDest, s_fileDate, s_fileTime )
ENDIF
ENDIF
ENDIF
RETURN nTotBytes
| fcopy.prg | 143 |
FUNCTION | FILECCLOSE()
FUNCTION FILECCLOSE()
IF s_hSrcFile != -1
FCLOSE( s_hSrcFile )
s_hSrcFile := -1
RETURN .T.
ENDIF
RETURN .F.
| fcopy.prg | 179 |
FUNCTION | FILEAPPEND( cSrc, cDest )
FUNCTION FILEAPPEND( cSrc, cDest )
LOCAL cBuffer := Space( F_BLOCK )
LOCAL hSrcFile, hDstFile
LOCAL nSrcBytes, nDstBytes, nTotBytes := 0
hSrcFile := FOPEN( cSrc, FO_READ )
IF hSrcFile != -1
IF !FILE( cDest )
hDstFile := FCREATE( cDest )
ELSE
hDstFile := FOPEN( cDest, FO_WRITE )
FSEEK( hDstFile, 0, FS_END )
ENDIF
IF hDstFile != -1
DO WHILE .T.
nSrcBytes := FREAD( hSrcFile, @cBuffer, F_BLOCK )
IF nSrcBytes == 0
EXIT
ENDIF
nDstBytes := FWRITE( hDstFile, cBuffer, nSrcBytes )
IF nDstBytes < nSrcBytes
EXIT
ENDIF
nTotBytes += nDstBytes
ENDDO
FCLOSE( hDstFile )
ENDIF
FCLOSE( hSrcFile )
ENDIF
RETURN nTotBytes
| fcopy.prg | 188 |
getinfo.prg |
Type | Function | Source | Line |
FUNCTION | SAVEGETS()
FUNCTION SAVEGETS()
LOCAL aGetList := GetList
GetList := {}
RETURN aGetList
| getinfo.prg | 60 |
FUNCTION | RESTGETS( aGetList )
FUNCTION RESTGETS( aGetList )
RETURN ( GetList := aGetList ) != NIL
| getinfo.prg | 65 |
FUNCTION | COUNTGETS()
FUNCTION COUNTGETS()
RETURN LEN( GetList )
| getinfo.prg | 68 |
FUNCTION | CURRENTGET()
FUNCTION CURRENTGET()
LOCAL oActive := GetActive()
RETURN ASCAN( GetList, {|oGet| oGet == oActive } )
| getinfo.prg | 71 |
FUNCTION | GETFLDROW( nField )
FUNCTION GETFLDROW( nField )
LOCAL oGet
IF !ISNUMBER( nField )
oGet := GetActive()
ELSEIF nField >= 1 .AND. nField <= LEN( GetList )
oGet := GetList[ nField ]
ENDIF
RETURN IIF( oGet != NIL, oGet:Row, -1 )
| getinfo.prg | 75 |
FUNCTION | GETFLDCOL( nField )
FUNCTION GETFLDCOL( nField )
LOCAL oGet
IF !ISNUMBER( nField )
oGet := GetActive()
ELSEIF nField >= 1 .AND. nField <= LEN( GetList )
oGet := GetList[ nField ]
ENDIF
RETURN IIF( oGet != NIL, oGet:Col, -1 )
| getinfo.prg | 84 |
FUNCTION | GETFLDVAR( nField )
FUNCTION GETFLDVAR( nField )
LOCAL oGet
IF !ISNUMBER( nField )
oGet := GetActive()
ELSEIF nField >= 1 .AND. nField <= LEN( GetList )
oGet := GetList[ nField ]
ENDIF
RETURN IIF( oGet != NIL, oGet:Name, -1 )
| getinfo.prg | 93 |
getinput.prg |
Type | Function | Source | Line |
FUNCTION | GETINPUT( xVar, nRow, nCol, lSay, xPrompt )
FUNCTION GETINPUT( xVar, nRow, nCol, lSay, xPrompt )
LOCAL nCursorRow := ROW()
LOCAL nCursorCol := COL()
LOCAL GetList := {}
IF !ISNUMBER( nRow )
nRow := nCursorRow
ENDIF
IF !ISNUMBER( nCol )
nCol := nCursorCol
ENDIF
IF !ISLOGICAL( lSay )
lSay := .F.
ENDIF
SETPOS( nRow, nCol )
IF xPrompt != Nil
DEVOUT( xPrompt )
nRow := ROW()
nCol := COL() + 1
ENDIF
@ nRow, nCol GET xVar
READ
IF lSay
SETPOS( nRow, nCol )
DEVOUT( xVar )
ENDIF
SETPOS( nCursorRow, nCursorCol )
RETURN xVar
| getinput.prg | 58 |
getsecrt.prg |
Type | Function | Source | Line |
FUNCTION | GETSECRET( cVar, nRow, nCol, lSay, xPrompt )
FUNCTION GETSECRET( cVar, nRow, nCol, lSay, xPrompt )
LOCAL nCursorRow := ROW()
LOCAL nCursorCol := COL()
LOCAL GetList := {}
LOCAL _cGetSecret := cVar
LOCAL lHide := .T.
IF !ISNUMBER( nRow )
nRow := ROW()
ENDIF
IF !ISNUMBER( nCol )
nCol := COL()
ENDIF
IF !ISLOGICAL( lSay )
lSay := .F.
ENDIF
SETPOS( nRow, nCol )
IF xPrompt != Nil
DEVOUT( xPrompt )
nRow := ROW()
nCol := COL() + 1
ENDIF
SETPOS( nRow, nCol )
AADD( GetList, _GET_( _CGETSECRET, "_CGETSECRET",,, ) )
ATAIL( GetList ):reader := { |oGet, oGetList| _SECRET( @_cGetSecret, @lHide, ;
oGet, oGetList ) }
ATAIL( GetList ):block := { |xNew| _VALUE( @_cGetSecret, lHide, xNew ) }
READ
IF lSay
SETPOS( nRow, nCol )
DEVOUT( _HIDE( _cGetSecret ) )
ENDIF
SETPOS( nCursorRow, nCursorCol )
RETURN _cGetSecret
| getsecrt.prg | 59 |
STATIC FUNCTION | _HIDE( cVar )
STATIC FUNCTION _HIDE( cVar )
RETURN RANGEREPL( ASC( " " ) + 1, 255, cVar, "*" )
| getsecrt.prg | 99 |
STATIC FUNCTION | _VALUE( cVar, lHide, xNew )
STATIC FUNCTION _VALUE( cVar, lHide, xNew )
IF lHide
RETURN _HIDE( cVar )
ELSEIF xNew != NIL
cVar := PADR( xNew, LEN( cVar ) )
ENDIF
RETURN cVar
| getsecrt.prg | 102 |
STATIC PROCEDURE | _SECRET( _cGetSecret, lHide, oGet, oGetList )
STATIC PROCEDURE _SECRET( _cGetSecret, lHide, oGet, oGetList )
LOCAL nKey, nLen, bKeyBlock
IF oGetList == NIL
oGetList := __GetListActive()
ENDIF
IF GetPreValidate( oGet )
nLen := LEN( _cGetSecret )
oGet:SetFocus()
DO WHILE oGet:exitState == GE_NOEXIT
IF oGet:typeOut
oGet:exitState := GE_ENTER
ENDIF
DO WHILE oGet:exitState == GE_NOEXIT
nKey := INKEY( 0 )
IF ( bKeyBlock := SETKEY( nKey ) ) != NIL
lHide := .F.
EVAL( bKeyBlock, oGetList:cReadProcName, ;
oGetList:nReadProcLine, oGetList:ReadVar() )
lHide := .T.
LOOP
ELSEIF nKey >= 32 .AND. nKey <= 255
IF SET( _SET_INSERT )
_cGetSecret := STUFF( LEFT( _cGetSecret, nLen - 1), ;
oGet:pos, 0, CHR( nKey ) )
ELSE
_cGetSecret := STUFF( _cGetSecret, oGet:pos, 1, CHR( nKey ) )
ENDIF
nKey := ASC( "*" )
ENDIF
GetApplyKey( oGet, nKey )
ENDDO
IF !GetPostValidate( oGet )
oGet:exitState := GE_NOEXIT
ENDIF
ENDDO
oGet:KillFocus()
ENDIF
RETURN
| getsecrt.prg | 110 |
keysave.prg |
Type | Function | Source | Line |
FUNCTION | SAVESETKEY()
FUNCTION SAVESETKEY()
RETURN HB_SETKEYSAVE()
| keysave.prg | 52 |
FUNCTION | RESTSETKEY( aSavedTraps )
FUNCTION RESTSETKEY( aSavedTraps )
HB_SETKEYSAVE( aSavedTraps )
RETURN .T.
| keysave.prg | 55 |
keysec.prg |
Type | Function | Source | Line |
FUNCTION | KeySec( nKey, nTime, nCounter, lMode )
FUNCTION KeySec( nKey, nTime, nCounter, lMode )
LOCAL nSeconds
IF s_hIdle != NIL
HB_IDLEDEL( s_hIdle )
s_hIdle := NIL
ENDIF
IF ISNUMBER( nKey )
IF !ISNUMBER( nTime )
nTime := 0
ELSEIF nTime < 0
nTime := -nTime / 18.2
ENDIF
IF !ISNUMBER( nCounter )
nCounter := 1
ENDIF
IF !ISLOGICAL( lMode )
lMode := .f.
ENDIF
nSeconds := SECONDS()
s_hIdle := HB_IDLEADD( {|| doKeySec( nKey, nTime, lMode, ;
@nCounter, @nSeconds ) } )
RETURN .T.
ENDIF
RETURN .F.
| keysec.prg | 57 |
STATIC PROCEDURE | doKeySec( nKey, nTime, lMode, nCounter, nSeconds )
STATIC PROCEDURE doKeySec( nKey, nTime, lMode, nCounter, nSeconds )
LOCAL nSec := SECONDS()
IF lMode .AND. ! EMPTY( NEXTKEY() )
nSeconds := nSec
ELSEIF nCounter != 0 .AND. nSec - nSeconds >= nTime
__KEYBOARD( nKey )
IF nCounter > 0
nCounter--
ENDIF
IF nCounter == 0
HB_IDLEDEL( s_hIdle )
s_hIdle := NIL
ELSE
nSeconds := nSec
ENDIF
ENDIF
RETURN
| keysec.prg | 86 |
keytime.prg |
Type | Function | Source | Line |
FUNCTION | KeyTime( nKey, cClockTime )
FUNCTION KeyTime( nKey, cClockTime )
LOCAL nHour, nMin, nSec, nLast
IF s_hIdle != NIL
HB_IDLEDEL( s_hIdle )
s_hIdle := NIL
ENDIF
IF ISNUMBER( nKey ) .AND. ISCHARACTER( cClockTime )
nHour := VAL( SUBSTR( cClockTime, 1, 2 ) )
nMin := VAL( SUBSTR( cClockTime, 4, 2 ) )
nSec := VAL( SUBSTR( cClockTime, 7, 2 ) )
nLast := -1
s_hIdle := HB_IDLEADD( {|| doKeyTime( nKey, cClockTime, nHour, nMin, nSec, ;
@nLast ) } )
RETURN .T.
ENDIF
RETURN .F.
| keytime.prg | 57 |
STATIC PROCEDURE | doKeyTime( nKey, cClockTime, nHour, nMin, nSec, nLast )
STATIC PROCEDURE doKeyTime( nKey, cClockTime, nHour, nMin, nSec, nLast )
LOCAL ccTime := TIME()
LOCAL nHr := VAL( SUBSTR( ccTime, 1, 2 ) )
LOCAL nMn := VAL( SUBSTR( ccTime, 4, 2 ) )
LOCAL nSc := VAL( SUBSTR( ccTime, 7, 2 ) )
IF nHour == 99
IF nHr > nLast
__KEYBOARD( nKey )
nLast := nHr
IF nHr == 23
HB_IDLEDEL( s_hIdle )
s_hIdle := NIL
ENDIF
ENDIF
ELSEIF nMin == 99 .AND. nHr == nHour
IF nMn > nLast
__KEYBOARD( nKey )
nLast := nMn
IF nMn == 59
HB_IDLEDEL( s_hIdle )
s_hIdle := NIL
ENDIF
ENDIF
ELSEIF nSec == 99 .AND. nHr == nHour .AND. nMn == nMin
IF nSc > nLast
__KEYBOARD( nKey )
nLast := nSc
IF nSc == 59
HB_IDLEDEL( s_hIdle )
s_hIdle := NIL
ENDIF
ENDIF
ELSEIF ccTime > cClockTime
__KEYBOARD( nKey )
HB_IDLEDEL( s_hIdle )
s_hIdle := NIL
ENDIF
RETURN
| keytime.prg | 76 |
numconv.prg |
Type | Function | Source | Line |
FUNCTION | NTOC( xNum, nBase, nLenght, cPad )
FUNCTION NTOC( xNum, nBase, nLenght, cPad )
LOCAL cNum
Default cPad to " "
Default nBase to 10
IF VALTYPE( xNum ) == "C"
xNum := UPPER( ALLTRIM( xNum ) )
xNum := CTON( xNum, 16 )
ENDIF
IF nBase > 36 .OR. nBase < 2
RETURN ""
ENDIF
if xNum < 0
xNum += 4294967296
endif
cNum := B10TOBN( xNum, @nBase )
IF ISNUMBER( nLenght )
IF LEN(cNum) > nLenght
cNum := REPLICATE( "*", nLenght )
ELSEIF ISCHARACTER( cPad ) .AND. LEN( cNum ) < nLenght
cNum := REPLICATE( cPad, nLenght - LEN( cNum ) ) + cNum
ENDIF
ENDIF
RETURN cNum
| numconv.prg | 85 |
FUNCTION | CTON( xNum, nBase, lMode )
FUNCTION CTON( xNum, nBase, lMode )
LOCAL i, nNum := 0, nPos
Default lMode TO .F.
Default nBase TO 10
IF ISCHARACTER(xNum) .and. nBase >= 2 .and. nBase <= 36
xNum := UPPER( ALLTRIM( xNum) )
FOR i=1 TO LEN( xNum )
nPos := AT( SUBSTR( xNum, i, 1 ), WORLD )
IF nPos == 0 .or. nPos > nBase
EXIT
ELSE
nNum := nNum * nBase + ( nPos - 1 )
ENDIF
NEXT
IF lMode
IF nNum > 32767
nNum := nNum - 65536
ENDIF
ENDIF
ENDIF
RETURN nNum
| numconv.prg | 141 |
STATIC FUNCTION | B10TOBN( nNum, nBase )
STATIC FUNCTION B10TOBN( nNum, nBase )
LOCAL nInt
IF nNum > 0
nInt := INT( nNum / nBase)
RETURN IIF(nInt==0, "", B10TOBN( nInt, @nBase )) +;
SUBSTR( WORLD, ( nNum % nBase ) + 1, 1 )
ELSEIF nNum == 0
RETURN "0"
ENDIF
RETURN ""
| numconv.prg | 171 |
FUNCTION | BITTOC( nInteger, cBitPattern, lMode )
FUNCTION BITTOC( nInteger, cBitPattern, lMode )
LOCAL cBinary, nI, cString := ''
Default lMode TO .F.
cBitPattern := RIGHT( cBitPattern, 16 )
cBinary := NTOC( nInteger, 2, 16 )
FOR nI := 1 TO 16
IF SUBSTR( cBinary, -nI, 1 ) == '1'
cString := SUBSTR( cBitPattern, -nI, 1 ) + cString
ELSEIF lMode
cString := ' ' + cString
ENDIF
NEXT
RETURN RIGHT( cString, LEN( cBitPattern ) )
| numconv.prg | 211 |
FUNCTION | CTOBIT( cCharString, cBitPattern )
FUNCTION CTOBIT( cCharString, cBitPattern )
LOCAL nI, cString := ''
cCharString := RIGHT( cCharString, 16 )
cBitPattern := RIGHT( cBitPattern, 16 )
FOR nI := 1 TO LEN( cBitPattern )
cString := IF( AT(SUBSTR( cBitPattern, -nI, 1), cCharString) > 0, '1', '0') + cString
NEXT
RETURN CTON( cString, 2 )
| numconv.prg | 263 |
screen3.prg |
Type | Function | Source | Line |
FUNCTION | CLEAREOL( nRow, nCol, xAttr, xChar )
FUNCTION CLEAREOL( nRow, nCol, xAttr, xChar )
IF !ISNUMBER( nRow )
nRow := ROW()
ENDIF
RETURN CLEARWIN( nRow, nCol, nRow, /*MAXCOL()*/, xAttr, xChar )
| screen3.prg | 58 |
FUNCTION | CLEOL( nRow, nCol )
FUNCTION CLEOL( nRow, nCol )
IF !ISNUMBER( nRow )
nRow := ROW()
ENDIF
RETURN CLEARWIN( nRow, nCol, nRow, /*MAXCOL()*/, 7 /*"W/N"*/, " " )
| screen3.prg | 64 |
FUNCTION | CLWIN( nRow, nCol )
FUNCTION CLWIN( nRow, nCol )
RETURN CLEARWIN( nRow, nCol, /*MAXROW()*/, /*MAXCOL()*/, 7 /*"W/N"*/, " " )
| screen3.prg | 70 |
scrmark.prg |
Type | Function | Source | Line |
FUNCTION | SCREENMARK( cSearch, xAttr, lUpperLower, lAll, cForward, cTrailing )
FUNCTION SCREENMARK( cSearch, xAttr, lUpperLower, lAll, cForward, cTrailing )
LOCAL lFound := .f., nCount := 1
LOCAL nAt, nLen, nLast, nRow, nCol, nEnd, nCols
LOCAL cScreen
IF !ISLOGICAL( lUpperLower )
lUpperLower := .F.
ENDIF
IF !ISLOGICAL( lAll )
lAll := .F.
ENDIF
IF !ISCHARACTER( cForward ) .OR. cForward == ""
cForward := NIL
ENDIF
IF !ISCHARACTER( cTrailing ) .OR. cTrailing == ""
cTrailing := NIL
ENDIF
nCols := MAXCOL()
cScreen := SCREENTEXT( 0, 0, MAXROW(), nCols++ )
nLen := LEN( cSearch )
nLast := LEN( cScreen ) - nLen + 1
IF ! lUpperLower
cSearch := UPPER( cSearch )
cScreen := UPPER( cScreen )
ENDIF
DO WHILE ( nAt := ATNUM( cSearch, cScreen, nCount ) ) != 0
IF ( nAt == 1 .OR. cForward == NIL .OR. ;
SUBSTR( cScreen, nAt, 1 ) $ cForward ) .AND. ;
( nAt == nLast .OR. cTrailing == NIL .OR. ;
SUBSTR( cScreen, nAt + nLen ) $ cTrailing )
lFound := .t.
--nAt
nRow := INT( nAt / nCols )
nCol := INT( nAt % nCols )
nEnd := nCol + LEN( cSearch ) - 1
COLORWIN( nRow, nCol, nRow, nEnd, xAttr )
DO WHILE nEnd >= nCols
nEnd -= nCols
nCol := 0
++nRow
COLORWIN( nRow, nCol, nRow, nEnd, xAttr )
ENDDO
IF ! lAll
EXIT
ENDIF
ENDIF
nCount++
ENDDO
RETURN lFound
| scrmark.prg | 60 |
showtime.prg |
Type | Function | Source | Line |
FUNCTION | SHOWTIME( nRow, nCol, lNoSec, cColor, l12, lAmPm )
FUNCTION SHOWTIME( nRow, nCol, lNoSec, cColor, l12, lAmPm )
STATIC s_hTimer := NIL
IF VALTYPE( nRow ) == "N" .AND. nRow >= 0 .AND. nRow <= MAXROW( .T. )
IF s_hTimer != NIL
HB_IDLEDEL( s_hTimer )
ENDIF
s_hTimer := HB_IDLEADD( {|| _HB_CTDSPTIME( nRow, nCol, lNoSec, cColor, ;
l12, lAmPm ) } )
ELSEIF s_hTimer != NIL
HB_IDLEDEL( s_hTimer )
s_hTimer := NIL
ENDIF
RETURN ""
| showtime.prg | 54 |
|