Geetings list,
I recently tried adding a new custom colour code in the format..
<ANSI_CUSTOM>number<ANSI_END>
...My problem lies within in a string formating function,
I just cannot get it to format with custom color codes.
Everything else i got working.
/* snip, originaly format_str_len by Taka*/
void stringf ( char *buffer, int length, enum align_flags align, char *fill,
char *string )
{
char buf[MSL];
char buf2[MSL];
char *new_string;
char *count_string;
char temp;
int count = 0, nCount = 0;
int pos = 0;
new_string = buf;
count_string = buf2;
strcpy ( buf2, string );
if ( !fill )
fill = " ";
if ( length == 0 )
length = strlen_color ( BAR_1 ) - 2;
while ( *count_string && nCount != length )
{
temp = *count_string++;
if ( temp == ANSI_KEY )
{
temp = *count_string++;
if ( temp == ANSI_KEY)
nCount++;
continue;
}
else if ( temp == ANSI_CUSTOM )
{
temp = *count_string++;
while(temp != ANSI_END)
temp = *count_string++;
continue;
}
nCount++;
}
switch(align)
{
case ALIGN_RIGHT:
count = ( length - ++nCount );
while ( nCount++ <= length )
{
buf[pos++] = *fill;
}
break;
case ALIGN_CENTER:
nCount = ( length - nCount ) / 2;
count = nCount;
while ( nCount-- > 0 )
{
buf[pos++] = *fill;
}
break;
default:
break;
}
while ( *string && count != length )
{
temp = *string++;
buf[pos++] = temp;
if ( temp == ANSI_KEY)
{
buf[pos] = *string++;
if ( buf[pos] == ANSI_KEY)
count++;
pos++;
continue;
}
else if ( temp == ANSI_CUSTOM )
{
buf[pos] = *string++;
while(buf[pos] != ANSI_END)
buf[pos++] = *string++;
continue;
}
count++;
}
while ( count++ < length )
buf[pos++] = *fill;
buf[pos] = '\0';
strncpy ( buffer, new_string, length );
return;
}
Can anyone see what I'm doing wrong?
Markanth.
=====================================
Ryan Jennings - [EMAIL PROTECTED]
Markanth - [EMAIL PROTECTED]
http://spaceservices.net/~markanth
telnet://spaceservices.net:3778
=====================================