| 118 |
cache.data_len = header_len + strlen(content); |
cache.data_len = header_len + strlen(content); |
| 119 |
|
|
| 120 |
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); |
| 121 |
|
|
| 122 |
|
if (header_len != cache.line_offsets[header_line_cnt]) |
| 123 |
|
{ |
| 124 |
|
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]); |
| 125 |
|
header_len = (size_t)cache.line_offsets[header_line_cnt]; |
| 126 |
|
} |
| 127 |
|
|
| 128 |
cache.line_total = header_line_cnt + |
cache.line_total = header_line_cnt + |
| 129 |
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); |
| 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; |
| 245 |
return -3; |
return -3; |
| 246 |
} |
} |
| 247 |
|
|
| 248 |
|
bzero(p_cache, sizeof(*p_cache)); |
| 249 |
memcpy((void *)p_cache, p_mmap, (size_t)(((ARTICLE_CACHE *)p_mmap)->mmap_len - ((ARTICLE_CACHE *)p_mmap)->data_len)); |
memcpy((void *)p_cache, p_mmap, (size_t)(((ARTICLE_CACHE *)p_mmap)->mmap_len - ((ARTICLE_CACHE *)p_mmap)->data_len)); |
| 250 |
|
|
| 251 |
p_cache->p_mmap = p_mmap; |
p_cache->p_mmap = p_mmap; |