Function _conWLockC() Foundation
Locks a string container for direct write access.
XPPAPIRET _conWLockC(ContainerHandle chs, CHAR **ppstr,
ULONG *pulSize);
The function returns an error code (XPP_ERR_...) when the container chs is not a character string or when the write access failed (e.g. if there is already a read-lock on the container). If the return value is NULL, the operation was successful.
Especially for long strings this function is used to change the value of a string container directly. The returned pointer may be used to write into the string. However, the length of the string can be changed only after write access was finished with _conUnlockC(). The call of _conUnlockC() should be done as soon as possible, as the garbage collector may be blocked otherwise.
Please note that a NULL character is guaranteed after the end of the string but the string itself may contain NULL characters, too.
#include <ctype.h> /* isalpha(), tolower(), toupper() */
#include "xpppar.h"
#include "xppcon.h"
/*
FT_PROPER( <cString> ) -> cProperName
Note: To use isalpha(), toupper() and tolower() the
C-library has to be initialised first!
*/
XPPRET XPPENTRY FT_PROPER( XppParamList paramList )
{
ContainerHandle chParam;
CHAR *pc;
ULONG srcLen;
ULONG i;
BOOL doCap = TRUE;
/*
Get copy of parameter 1 (As long as the third parameter
is NULL _conParam asserts that a copy is generated
even when the parameter is passed by reference )
*/
chParam = _conParam( paramList, 1, NULL );
if (chParam != NULLCONTAINER)
{
if (! _conWLockC( chParam, &pc, &srcLen ))
{
for( i = 0; i < srcLen + 1; i++ )
{
if( isalpha( pc[i] ) )
{
if( doCap )
pc[i] = toupper( pc[i] );
else
pc[i] = tolower( pc[i] );
}
doCap = ( pc[i] == ' ' || pc[i] == '-' || pc[i] == '\'' );
}
for( i = 0; i <= srcLen; i++ )
if( pc[i] == 'M' && pc[i+1] == 'c' )
pc[i+2] = toupper( pc[i+2] );
_conUnlockC( chParam );
_conReturn( paramList, chParam );
}
else
_retc( paramList, "" );
_conRelease( chParam );
}
else
_retc( paramList, "" );
return;
}
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.