int call_raw_print_msg(PANEL *panel, sip_msg_t *msg) { call_raw_info_t *info; int payload_lines, i, column, height, width; // Message ngrep style Header char header[256]; char payload[2048]; int color = 0; // Get panel information if (!(info = call_raw_info(panel))) return -1; // Get the pad window WINDOW *pad = info->pad; // Get current pad dimensions getmaxyx(pad, height, width); // Get message payload strcpy(payload, msg_get_payload(msg)); // Check how many lines we well need to draw this message payload_lines = 0; column = 0; for (i = 0; i < strlen(payload); i++) { if (column == width || payload[i] == '\n') { payload_lines++; column = 0; continue; } column++; } // Check if we have enough space in our huge pad to store this message if (info->padline + payload_lines > height) { // Create a new pad with more lines! pad = newpad(height + 500, COLS); // And copy all previous information overwrite(info->pad, pad); // Delete previous pad delwin(info->pad); // And store the new pad info->pad = pad; } // Color the message { if (setting_has_value(SETTING_COLORMODE, "request")) { // Determine arrow color if (msg_is_request(msg)) { color = CP_RED_ON_DEF; } else { color = CP_GREEN_ON_DEF; } } else if (info->group && setting_has_value(SETTING_COLORMODE, "callid")) { // Color by call-id color = call_group_color(info->group, msg->call); } else if (setting_has_value(SETTING_COLORMODE, "cseq")) { // Color by CSeq within the same call color = msg->cseq % 7 + 1; } // Turn on the message color wattron(pad, COLOR_PAIR(color)); // Print msg header wattron(pad, A_BOLD); mvwprintw(pad, info->padline++, 0, "%s", sip_get_msg_header(msg, header)); wattroff(pad, A_BOLD); // Print msg payload info->padline += draw_message_pos(pad, msg, info->padline); // Extra line between messages info->padline++; // Set this as the last printed message info->last = msg; return 0; }
int draw_message(WINDOW *win, sip_msg_t *msg) { return draw_message_pos(win, msg, 0); }