asciisum.c |
Type | Function | Source | Line |
HB_FUNC | GT_ASCIISUM(void)
HB_FUNC( GT_ASCIISUM )
{
char *str;
int len, i;
long ascSum = 0;
str = hb_parc(1);
len = hb_parclen(1);
for (i = 0; i <= len; i++,str++) {
ascSum += *str;
}
hb_retnl(ascSum);
}
| asciisum.c | 22 |
ascpos.c |
Type | Function | Source | Line |
HB_FUNC | GT_ASCPOS(void)
HB_FUNC( GT_ASCPOS )
{
char *s;
ULONG p;
if (ISCHAR(1) && ISNUM(2)) {
s = hb_parc(1);
p = hb_parni(2);
p--; /* decrement p to adjust for c strings */
/* starting at position 0 */
if (p > hb_parclen(1)) /* oh oh p > length of passed string */
hb_retni(-2); /* error -2 */
else
hb_retni((int) s[p]); /* return ascii code of appropriate */
/* character in string */
} else {
hb_retni(-1); /* parameter mismatch - error -1 */
}
}
| ascpos.c | 22 |
atdiff.c |
Type | Function | Source | Line |
HB_FUNC | GT_ATDIFF(void)
HB_FUNC( GT_ATDIFF )
{
char *s1, *s2;
int pos, len;
if (ISCHAR(1) && ISCHAR(2)) {
s1 = hb_parc(1);
s2 = hb_parc(2);
len = hb_parclen(2);
/*
loop through comparing both strings
NOTE: pos starts at 1, so as to return a string index
for CLIPPER
*/
for (pos = 1; (pos <= len) && (*s1 == *s2); s2++, s1++)
pos++;
if (pos > len) /* strings match exactly!!! */
hb_retni(0);
else
hb_retni(pos);
} else {
hb_retni(-1); /* parameter mismatch - error -1 */
}
}
| atdiff.c | 22 |
bitflags.c |
Type | Function | Source | Line |
HB_FUNC | GT_NEWFLAG(void)
HB_FUNC( GT_NEWFLAG )
{
char *FlagString;
unsigned ByteCount;
unsigned FlagCount = 1;
unsigned Byte;
if (ISNUM(1))
{
FlagCount = (unsigned) hb_parni(1);
}
if (FlagCount > 0)
{
ByteCount = (unsigned)((FlagCount / 8) + 1);
if (!(FlagCount % 8))
{
--ByteCount;
}
FlagString = hb_xgrab(ByteCount);
for (Byte = 0; Byte < ByteCount; Byte++)
{
FlagString[Byte] = 0;
}
hb_retclen(FlagString, ByteCount);
hb_xfree(FlagString);
}
else
{
hb_retc(NULL);
}
}
| bitflags.c | 33 |
HB_FUNC | GT_SETFLAG(void)
HB_FUNC( GT_SETFLAG )
{
char *FlagString;
unsigned StartBit = 1;
unsigned EndBit = 1;
unsigned BitCount;
unsigned BitPointer;
unsigned BytePointer;
if ( ISCHAR(1) )
{
FlagString = hb_parc(1);
if ( ISNUM(2) )
{
StartBit = hb_parni(2);
}
if ( ISNUM(3) )
{
EndBit = hb_parni(3);
}
EndBit = _GT_MAX(StartBit, EndBit);
if (StartBit > 0 && EndBit <= (hb_parclen(1) * 8))
{
for (BitCount = StartBit; BitCount <= EndBit; BitCount++)
{
BitPointer = BitCount % 8;
BytePointer = (unsigned) (BitCount / 8);
if (!BitPointer)
{
BitPointer = 8;
--BytePointer;
}
FlagString[BytePointer] |= 1 << (BitPointer - 1);
}
}
hb_retclen(FlagString, hb_parclen(1));
}
else
{
hb_retc(NULL);
}
}
| bitflags.c | 65 |
HB_FUNC | GT_CLRFLAG(void)
HB_FUNC( GT_CLRFLAG )
{
char *FlagString;
unsigned StartBit = 1;
unsigned EndBit = 1;
unsigned BitCount;
unsigned BitPointer;
unsigned BytePointer;
if ( ISCHAR(1) )
{
FlagString = hb_parc(1);
if ( ISNUM(2) )
{
StartBit = hb_parni(2);
}
if ( ISNUM(3) )
{
EndBit = hb_parni(3);
}
EndBit = _GT_MAX(StartBit, EndBit);
if (StartBit > 0 && EndBit <= (hb_parclen(1) * 8))
{
for (BitCount = StartBit; BitCount <= EndBit; BitCount++)
{
BitPointer = BitCount % 8;
BytePointer = (unsigned) (BitCount / 8);
if (!BitPointer)
{
BitPointer = 8;
--BytePointer;
}
FlagString[BytePointer] &= 0xff - (1 << (BitPointer - 1));
}
}
hb_retclen(FlagString, hb_parclen(1));
}
else
{
hb_retc(NULL);
}
}
| bitflags.c | 108 |
HB_FUNC | GT_ISFLAG(void)
HB_FUNC( GT_ISFLAG )
{
BOOL FlagStatus = FALSE;
unsigned Bit = 1;
unsigned BitPointer;
unsigned BytePointer;
char *FlagString;
if ( ISCHAR(1) )
{
FlagString = hb_parc(1);
if ( ISNUM(2) )
{
Bit = hb_parni(2);
}
if (Bit > 0 && Bit <= (hb_parclen(1) * 8))
{
BitPointer = Bit % 8;
BytePointer = (unsigned) (Bit / 8);
if (!BitPointer)
{
BitPointer = 8;
--BytePointer;
}
FlagStatus = FlagString[BytePointer] & (1 << (BitPointer - 1));
}
}
hb_retl(FlagStatus);
}
| bitflags.c | 151 |
chareven.c |
Type | Function | Source | Line |
HB_FUNC | GT_CHAREVEN(void)
HB_FUNC( GT_CHAREVEN )
{
char *s1, *s2;
int len, i;
if (ISCHAR(1)) {
s1 = hb_parc(1);
len = hb_parclen(1);
s2 = (char *)hb_xgrab(len / 2); /* grab us some mem to work with */
for (i = 1; i <= len; i += 2)
s2[(i - 1)/2] = s1[i] & 0x7f;
hb_retclen(s2, len);
hb_xfree(s2); /* free alloc'ed mem */
} else {
hb_retc((char *) NULL); /* parameter mismatch - error NullStr */
}
}
| chareven.c | 22 |
charmix.c |
Type | Function | Source | Line |
HB_FUNC | GT_CHARMIX(void)
HB_FUNC( GT_CHARMIX )
{
char *s1, *s2, *s3;
int l1, l2, i, pos3;
if (ISCHAR(1) && ISCHAR(2)) {
s1 = hb_parc(1);
s2 = hb_parc(2);
l1 = hb_parclen(1);
l2 = hb_parclen(2);
pos3 = 0;
s3 = (char*)hb_xgrab(l1 + l2 + 1); /* grab us some mem to work with */
for (i = 0; i < l1; i++) {
s3[pos3++] = s1[i];
if (i < l2)
s3[pos3++] = s2[i];
}
if (l2 > l1)
for (; i < l2; i++)
s3[pos3++] = s2[i];
s3[pos3] = '\0';
hb_retclen(s3, l1 + l2);
hb_xfree(s3); /* free alloc'ed mem */
} else {
hb_retc((char *) NULL); /* parameter mismatch - error NullStr */
}
}
| charmix.c | 22 |
charodd.c |
Type | Function | Source | Line |
HB_FUNC | GT_CHARODD(void)
HB_FUNC( GT_CHARODD )
{
char *s1, *s2;
int len, i;
if (ISCHAR(1)) {
s1 = hb_parc(1);
len = hb_parclen(1);
s2 = (char *)hb_xgrab(len / 2); /* grab us some mem to work with */
for (i = 0; i <= len; i += 2)
s2[i/2] = s1[i] & 0x7f;
hb_retclen(s2, len);
hb_xfree(s2); /* free alloc'ed mem */
} else {
hb_retc((char *) NULL); /* parameter mismatch - error NullStr */
}
}
| charodd.c | 22 |
chrcount.c |
Type | Function | Source | Line |
HB_FUNC | GT_CHRCOUNT(void)
HB_FUNC( GT_CHRCOUNT )
{
char *s1, *s2;
int count, pos2, len;
if (ISCHAR(1) && ISCHAR(2)) {
s1 = hb_parc(1);
s2 = hb_parc(2);
len = hb_parclen(2);
/* loop through s2 matching passed character (s1) with
each character of s1 */
for (count = 0, pos2 = 1; pos2 <= len; s2++, pos2++)
if (*s1 == *s2) /* character matches s1 */
count++; /* increment counter */
hb_retni(count); /* return result */
} else {
hb_retni(-1); /* parameter mismatch - error -1 */
}
}
| chrcount.c | 22 |
chrfirst.c |
Type | Function | Source | Line |
HB_FUNC | GT_CHRFIRST(void)
HB_FUNC( GT_CHRFIRST )
{
char *string;
char *cset;
int l1, l2;
int p1, p2;
if (ISCHAR(1) && ISCHAR(2)) {
string = hb_parc(2);
cset = hb_parc(1);
l1 = hb_parclen(2);
l2 = hb_parclen(1);
p1 = p2 = 0;
do {
for (p2 = 0; (p2 < l2) && (cset[p2] != string[p1]); ++p2)
;
if (p2 < l2) {
hb_retni(string[p1]);
break;
}
} while (p1++ < l1);
if (p2 >= l2)
hb_retni(0);
} else {
hb_retni(-1); /* parameter mismatch - error NullStr */
}
}
| chrfirst.c | 22 |
chrtotal.c |
Type | Function | Source | Line |
HB_FUNC | GT_CHRTOTAL(void)
HB_FUNC( GT_CHRTOTAL )
{
char *s1, *s2;
int count, p1, p2, l2, l1;
if (ISCHAR(1) && ISCHAR(2)) {
s1 = hb_parc(1);
s2 = hb_parc(2);
l2 = hb_parclen(2);
l1 = hb_parclen(1);
for (count = 0, p2 = 0; p2 < l2; p2++)
for (p1 = 0; p1 < l1; p1++)
if (s1[p1] == s2[p2])
count++; /* increment counter */
hb_retni(count); /* return result */
} else {
hb_retni(-1); /* parameter mismatch - error -1 */
}
}
| chrtotal.c | 22 |
strasint.c |
Type | Function | Source | Line |
INT | _GT_Internal_StringAsInt(char *String, int Start, int End)
int _GT_Internal_StringAsInt(char *String, int Start, int End)
{
int Decimal = 1;
int Digit;
int Value = 0;
HB_TRACE(HB_TR_DEBUG, ("_GT_Internal_StringAsInt(%s, %d, %d)", String, Start, End));
for (Digit = End; Digit >= Start; Digit--)
{
if (ISDIGIT(String[Digit]))
{
Value += (String[Digit] - 0x30) * Decimal;
Decimal *= 0xA;
}
}
return(Value);
}
| strasint.c | 16 |
strcount.c |
Type | Function | Source | Line |
HB_FUNC | GT_STRCOUNT(void)
HB_FUNC( GT_STRCOUNT )
{
char *s1, *s2;
int count, p1, p2, l1, l2;
int match;
if (ISCHAR(1) && ISCHAR(2)) {
s1 = hb_parc(1);
s2 = hb_parc(2);
l1 = hb_parclen(1);
l2 = hb_parclen(2);
/* loop through s2 matching passed character (s1) with
each character of s1 */
for (count = 0, p2 = 0; p2 <= (l2 - l1); p2++)
{
match = 1;
for (p1 = 0; p1 < l1; p1++)
{
if (s1[p1] != s2[p2 + p1])
match = 0;
}
if (match)
count++;
}
hb_retni(count); /* return result */
} else {
hb_retni(-1); /* parameter mismatch - error -1 */
}
}
| strcount.c | 22 |
strcspn.c |
Type | Function | Source | Line |
HB_FUNC | GT_STRCSPN(void)
HB_FUNC( GT_STRCSPN )
{
char *string;
char *cset;
int l1, l2;
int p1, p2;
if (ISCHAR(1) && ISCHAR(2)) {
string = hb_parc(1);
cset = hb_parc(2);
l1 = hb_parclen(1);
l2 = hb_parclen(2);
for (p1 = 0; p1 < l1; ++p1) {
for (p2 = 0; (p2 < l2) && (string[p1] != cset[p2]); ++p2)
;
if (p2 < l2)
break;
}
hb_retni(p1);
} else {
hb_retni(-1); /* parameter mismatch - error -1 */
}
}
| strcspn.c | 22 |
strdiff.c |
Type | Function | Source | Line |
HB_FUNC | GT_STRDIFF(void)
HB_FUNC( GT_STRDIFF )
{
char *s1, *s2;
int pos, len;
if (ISCHAR(1) && ISCHAR(2)) {
s1 = hb_parc(1);
s2 = hb_parc(2);
len = hb_parclen(2);
/*
loop through comparing both strings
NOTE: pos starts at 1, so as to return a string index
for CLIPPER
*/
for (pos = 1; (pos <= len) && (*s1 == *s2); s2++, s1++)
pos++;
if (pos > len) /* strings match exactly!!! */
hb_retc((char *) NULL);
else
hb_retc(s2);
} else {
hb_ret(); /* parameter mismatch - error return NIL */
}
}
| strdiff.c | 22 |
strexpan.c |
Type | Function | Source | Line |
HB_FUNC | GT_STREXPAND(void)
HB_FUNC( GT_STREXPAND )
{
char *in, *out;
int nIns = 1;
char *insert = " ";
int len;
int i, j, p;
if (ISCHAR(1) && (ISNUM(2) || hb_pcount() < 2) && (ISCHAR(3) || hb_pcount() < 3)) {
in = hb_parc(1);
len = hb_parclen(1);
if (ISNUM(2))
nIns = hb_parni(2);
if (ISCHAR(3))
insert = hb_parc(3);
out = (char *)hb_xgrab(len * (nIns + 1)); /* alloc us some memory */
for (i = 0, p = 0; i < len; i++) { /* loop thru input */
out[p++] = in[i]; /* insert a character from input */
if (i < (len - 1)) { /* do not insert fill chars on last */
/* char of input */
for (j = 1; j <= nIns; j++) /* insert the fill characters */
out[p++] = insert[0];
}
}
out[p] = '\0'; /* Add terminating NUL */
hb_retc(out);
hb_xfree(out); /* free alloc'ed mem */
} else {
hb_retc((char *) NULL); /* parameter mismatch - error NullStr */
}
}
| strexpan.c | 22 |
strleft.c |
Type | Function | Source | Line |
HB_FUNC | GT_STRLEFT(void)
HB_FUNC( GT_STRLEFT )
{
char *string;
char *cset;
int l1, l2;
int p1, p2;
if (ISCHAR(1) && ISCHAR(2)) {
string = hb_parc(1);
cset = hb_parc(2);
l1 = hb_parclen(1);
l2 = hb_parclen(2);
for (p1 = 0; p1 < l1; p1++) {
for (p2 = 0; p2 < l2 && cset[p2] != string[p1]; p2++)
;
if (p2 == l2)
break;
}
hb_retni(p1);
} else {
hb_retni(-1); /* parameter mismatch - error NullStr */
}
}
| strleft.c | 22 |
strpbrk.c |
Type | Function | Source | Line |
HB_FUNC | GT_STRPBRK(void)
HB_FUNC( GT_STRPBRK )
{
char *string;
char *cset;
int l1, l2;
int p1, p2;
if (ISCHAR(1) && ISCHAR(2)) {
string = hb_parc(1);
cset = hb_parc(2);
l1 = hb_parclen(1);
l2 = hb_parclen(2);
p1 = p2 = 0;
do {
for (p2 = 0; (p2 < l2) && (cset[p2] != string[p1]); ++p2)
;
if (p2 < l2) {
hb_retc(string + p1);
break;
}
} while (p1++ < l1);
if (p2 >= l2)
hb_retc((char *) NULL);
} else {
hb_retc((char *) NULL); /* parameter mismatch - error NullStr */
}
}
| strpbrk.c | 22 |
strright.c |
Type | Function | Source | Line |
HB_FUNC | GT_STRRIGHT(void)
HB_FUNC( GT_STRRIGHT )
{
char *string;
char *cset;
int l1, l2;
int p1, p2;
if (ISCHAR(1) && ISCHAR(2)) {
string = hb_parc(1);
cset = hb_parc(2);
l1 = hb_parclen(1);
l2 = hb_parclen(2);
for (p1 = l1 - 1; p1 >= 0; p1--) {
for (p2 = 0; p2 < l2 && cset[p2] != string[p1]; p2++)
;
if (p2 == l2)
break;
}
hb_retni(l1 - p1 - 1);
} else {
hb_retni(-1); /* parameter mismatch - error NullStr */
}
}
| strright.c | 22 |