/[LeafOK_CVS]/lbbs/src/article_cache.c
ViewVC logotype

Diff of /lbbs/src/article_cache.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.8 by sysadm, Sun Jun 1 14:04:19 2025 UTC Revision 1.10 by sysadm, Mon Jun 2 10:33:25 2025 UTC
# Line 118  int article_cache_generate(const char *c Line 118  int article_cache_generate(const char *c
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;
# Line 128  int article_cache_generate(const char *c Line 142  int article_cache_generate(const char *c
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;
# Line 224  int article_cache_load(ARTICLE_CACHE *p_ Line 245  int article_cache_load(ARTICLE_CACHE *p_
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;


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1