mxp_strlen.txt
snippets · 897 B · 2010-03-30
mxp_strlen: returns the length of a string containing MXP/HTML tags.
Download « Back to the snippets list
/*
** Just a simple function I came up with to return the length of a string
** that contains MXP/HTML tags. Based on the col_strlen function.
**
** My only request for using it is to leave the comment that with my name.
*/
Add the following line in one of your headers (proto.h, merc.h, mud.h or
which ever you use):
void mxp_strlen args( ( char *txt ) );
-----
Add the following function to one of your C files:
/*
** Mxp_strlen by Jindrak (jindrak@gmail.com)
*/
int mxp_strlen( char *txt )
{
int pos = 0, len = 0;
while(txt[pos] != NUL)
{
switch(txt[pos])
{
default:
pos++;
break;
case '<':
while(txt[pos++] != '>')
;
len--;
break;
}
len++;
}
return( len );
}