| 115 |
header_len = strnlen(header, sizeof(header)); |
header_len = strnlen(header, sizeof(header)); |
| 116 |
footer_len = strnlen(footer, sizeof(footer)); |
footer_len = strnlen(footer, sizeof(footer)); |
| 117 |
|
|
|
cache.data_len = header_len + strlen(content); |
|
|
|
|
| 118 |
header_line_cnt = split_data_lines(header, SCREEN_COLS, cache.line_offsets, MAX_SPLIT_FILE_LINES); |
header_line_cnt = split_data_lines(header, SCREEN_COLS, cache.line_offsets, MAX_SPLIT_FILE_LINES); |
| 119 |
|
|
| 120 |
|
if (header_len != cache.line_offsets[header_line_cnt]) |
| 121 |
|
{ |
| 122 |
|
log_std("Header of article(aid=%d) is truncated from %ld to %ld\n", p_article->aid, header_len, cache.line_offsets[header_line_cnt]); |
| 123 |
|
header_len = (size_t)cache.line_offsets[header_line_cnt]; |
| 124 |
|
} |
| 125 |
|
|
| 126 |
cache.line_total = header_line_cnt + |
cache.line_total = header_line_cnt + |
| 127 |
split_data_lines(content, SCREEN_COLS, cache.line_offsets + header_line_cnt, MAX_SPLIT_FILE_LINES - header_line_cnt); |
split_data_lines(content, SCREEN_COLS, cache.line_offsets + header_line_cnt, MAX_SPLIT_FILE_LINES - header_line_cnt); |
| 128 |
|
|
| 129 |
|
cache.data_len = header_len + strlen(content); |
| 130 |
|
|
| 131 |
|
if (cache.data_len - header_len != (size_t)cache.line_offsets[cache.line_total]) |
| 132 |
|
{ |
| 133 |
|
log_std("Body of article(aid=%d) is truncated from %ld to %ld\n", |
| 134 |
|
p_article->aid, cache.data_len - header_len, cache.line_offsets[cache.line_total]); |
| 135 |
|
cache.data_len = header_len + (size_t)(cache.line_offsets[cache.line_total]); |
| 136 |
|
} |
| 137 |
|
|
| 138 |
for (i = header_line_cnt; i <= cache.line_total; i++) |
for (i = header_line_cnt; i <= cache.line_total; i++) |
| 139 |
{ |
{ |
| 140 |
cache.line_offsets[i] += (long)header_len; |
cache.line_offsets[i] += (long)header_len; |
| 142 |
|
|
| 143 |
footer_line_cnt = split_data_lines(footer, SCREEN_COLS, cache.line_offsets + cache.line_total, MAX_SPLIT_FILE_LINES - cache.line_total); |
footer_line_cnt = split_data_lines(footer, SCREEN_COLS, cache.line_offsets + cache.line_total, MAX_SPLIT_FILE_LINES - cache.line_total); |
| 144 |
|
|
| 145 |
|
if (footer_len != cache.line_offsets[cache.line_total + footer_line_cnt]) |
| 146 |
|
{ |
| 147 |
|
log_std("Footer of article(aid=%d) is truncated from %ld to %ld\n", |
| 148 |
|
p_article->aid, footer_len, cache.line_offsets[cache.line_total + footer_line_cnt]); |
| 149 |
|
footer_len = (size_t)(cache.line_offsets[cache.line_total + footer_line_cnt]); |
| 150 |
|
} |
| 151 |
|
|
| 152 |
for (i = 0; i <= footer_line_cnt; i++) |
for (i = 0; i <= footer_line_cnt; i++) |
| 153 |
{ |
{ |
| 154 |
cache.line_offsets[cache.line_total + i] += (long)cache.data_len; |
cache.line_offsets[cache.line_total + i] += (long)cache.data_len; |