int Trim(char *pszString, int iLength )
{int iLen = iLength - 1;
/********************************************************************/
/* While we are not at the 1st char AND (a char is whitespace OR */
/* 0x00) keep backing up from end of string */
/********************************************************************/
pszString[iLength] = 0x00;
while ( (iLen >= 0) &&
((isspace(pszString[iLen]) ) || (0x00 == pszString[iLen])) ) {
iLen--;
} /* endwhile */
/********************************************************************/
/* if iLen unchanged, it means no trimming was done (no whitespace */
/* found). */
/********************************************************************/
if (iLen == (iLength-1)) {
return(iLen);
} /* endif */

Figure 302. Sample WSG Server Logon Exit Program (Part 49 of 50)

/********************************************************************/
/* if iLen >= 0, we found 1 or more chars, so mark end with a */
/* NULL terminator. */
/********************************************************************/
else if (iLen >= 0) {
pszString[iLen + 1] = 0x00;
} /* endif */
/********************************************************************/
/* else iLen < 0, which means we didn't find anything but whitespace*/
/********************************************************************/
else {
pszString[0] = 0x00;
} /* endelse */
iLen = strlen(pszString); return(iLen);
}
#undef _WSGEXIT_C
/**********************************************************************/
/* END OF WSGEXIT.C */
/**********************************************************************/

Figure 302. Sample WSG Server Logon Exit Program (Part 50 of 50)

594 OS/400 TCP/IPConfiguration and Reference V4R4