On Jul 25, 2008, at 3:23 PM, Kumar, Hemant wrote:
> Even if I comment as shown below and add a simple printf statement
> it fails but if I just keep the first line ep_alloc() and comment
> everything
> With no printf addition then it works.:--
>
> if (check_col(pinfo->cinfo,COL_INFO))
> {
>
> temp_str = ep_alloc(STRING_BUFFER);
> printf( "[%s] %s ", message->direction,
> message->message_type);
> // g_snprintf( temp_str, sizeof(temp_str), "[%s]
> %s ", message->direction, message->message_type);
> // col_add_str(pinfo->cinfo, COL_INFO, temp_str);
>
> }
So that sample does, or doesn't, work?
If it doesn't work, is the code that does work
if (check_col(pinfo->cinfo,COL_INFO))
{
temp_str = ep_alloc(STRING_BUFFER);
// printf( "[%s] %s ", message->direction,
message->message_type);
// g_snprintf( temp_str, sizeof(temp_str), "[%s]
%s ", message->direction, message->message_type);
// col_add_str(pinfo->cinfo, COL_INFO, temp_str);
}
or, equivalently:
if (check_col(pinfo->cinfo,COL_INFO))
{
temp_str = ep_alloc(STRING_BUFFER);
// g_snprintf( temp_str, sizeof(temp_str), "[%s]
%s ", message->direction, message->message_type);
// col_add_str(pinfo->cinfo, COL_INFO, temp_str);
}
(i.e., "just keep the first line ep_alloc()" and "comment everything
with no printf addition"?
By the way, there's a "col_add_fstr()" routine which takes a format
string and an argument list, so you can just do
if (check_col(pinfo->cinfo, COL_INFO))
{
col_add_fstr(pinfo->cinfo, COL_INFO, "[%s] %s ",
message-
>direction, message->message_type);
}
You also don't have to do
if (check_col(pinfo->cinfo,COL_INFO))
{
col_clear(pinfo->cinfo,COL_INFO);
}
if, immediately after that, you're going to set the string.
_______________________________________________
Wireshark-dev mailing list
[email protected]
https://wireshark.org/mailman/listinfo/wireshark-dev