| T X T _ B S T R N C A T ( )
| | | | | SOURCE: qdev_autodocs.txt 1.163 (12/09/2014) English
INDEP - TXT_#?
----------------------------------------------------------------------------
NAME
txt_bstrncat() - Concatenate BCPL string to NULL term.
string.
SYNOPSIS
len = txt_bstrncat(dst, src, dlen);
LONG txt_bstrncat(UBYTE *, LONG, LONG);
FUNCTION
This function appends BCPL string to NULL terminated one.
INPUTS
dst - Destination string.
src - Source BCPL string.
dlen - Destinantion length.
RETURNS
Returns amount of data that was put in the destination.
Overflow will be indicated by inverting the value, so neg.
result means that the data was truncated. 0 will mean that
no copy took place.
BASES
None.
NOTES
This function is slightly different than normal 'strncat()'
instead of length of source string it expects the dest.
length which is much safier on non-MMU systems.
This function can successfully be used as 'strncpy()' as
well. In such case you have to remember to NULL the first
byte of the destination buffer.
This func. comes with two more variants: 'txt_bstrncatlc()'
& 'txt_bstrncatuc()' who allow to transform the text on the
fly to lower or upper case.
Truncation can be detected by adding buffer size to the
output of the function. If it is 1 then the last call did
truncate the output.
Beware! Never create BCPL address to data put on stack!!!
All addresses to be BCPLed must be multiple of 4!
SEE ALSO
EXAMPLE
...
#define SIZE 256
...
/*
* This is how BCPL string look likes, first byte is length
* of the string and then the string. Pay attention to this
* 'static' it causes data not to be put on stack.
*/
static UBYTE bcplstr[] = {11, 'B', 'C', 'P', 'L', ' ',
's', 'u', 'c', 'k', 's', '!'};
LONG bcplptr = QDEV_HLP_MKBADDR(bcplstr); /* Non-direct ptr! */
UBYTE buf[SIZE] = {0};
txt_bstrncat(buf, bcplptr, SIZE);
BUGS
None known.
----------------------------------------------------------------------------
| |
| |