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

Diff of /lbbs/src/test_section_list.c

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

Revision 1.24 by sysadm, Mon May 26 03:32:55 2025 UTC Revision 1.34 by sysadm, Tue Oct 14 00:57:06 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                                          file_section_list.c  -  description                                          test_section_list.c  -  description
3                                                           -------------------                                                           -------------------
4          Copyright            : (C) 2004-2025 by Leaflet          Copyright            : (C) 2004-2025 by Leaflet
5          Email                : leaflet@leafok.com          Email                : leaflet@leafok.com
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
 #include "section_list.h"  
 #include "trie_dict.h"  
17  #include "bbs.h"  #include "bbs.h"
18  #include "log.h"  #include "log.h"
19    #include "section_list.h"
20    #include "trie_dict.h"
21    #include <errno.h>
22  #include <stdio.h>  #include <stdio.h>
23  #include <unistd.h>  #include <unistd.h>
 #include <errno.h>  
24    
25  #define ARTICLE_BLOCK_SHM_FILE "~article_block_shm.dat"  #define ARTICLE_BLOCK_SHM_FILE "~article_block_shm.dat"
26  #define SECTION_LIST_SHM_FILE "~section_list_shm.dat"  #define SECTION_LIST_SHM_FILE "~section_list_shm.dat"
# Line 33  const char *sname[] = { Line 33  const char *sname[] = {
33    
34  const char *stitle[] = {  const char *stitle[] = {
35          " Test Section ",          " Test Section ",
36          "ĸABC",          "字母组合ABC",
37          "__123"};          "_数字_123"};
38    
39  const char *master_name[] = {  const char *master_name[] = {
40          "sysadm",          "sysadm",
# Line 70  int main(int argc, char *argv[]) Line 70  int main(int argc, char *argv[])
70                  return -1;                  return -1;
71          }          }
72    
73          log_std_redirect(STDOUT_FILENO);          log_common_redir(STDOUT_FILENO);
74          log_err_redirect(STDERR_FILENO);          log_error_redir(STDERR_FILENO);
75    
76          // - 1 to make blocks allocated is less than required, to trigger error handling          // - 1 to make blocks allocated is less than required, to trigger error handling
77          block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK;          block_count = BBS_article_limit_per_section * BBS_max_section / ARTICLE_PER_BLOCK;
# Line 179  int main(int argc, char *argv[]) Line 179  int main(int argc, char *argv[])
179                          article.tid = 0;                          article.tid = 0;
180                          article.sid = i * 3 + 1;                          article.sid = i * 3 + 1;
181                          article.cid = article.aid;                          article.cid = article.aid;
182                          article.uid = 1; // TODO: randomize                          article.uid = 1;
183                          article.visible = 1;                          article.visible = 1;
184                          article.excerption = 0;                          article.excerption = 0;
185                          article.ontop = 0;                          article.ontop = 0;
186                          article.lock = 0;                          article.lock = 0;
187                            article.transship = 0;
188    
189                          if (section_list_rw_lock(p_section[i]) < 0)                          if (section_list_rw_lock(p_section[i]) < 0)
190                          {                          {
# Line 210  int main(int argc, char *argv[]) Line 211  int main(int argc, char *argv[])
211                  // printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i);                  // printf("Loaded %d articles into section %d\n", p_section[i]->article_count, i);
212          }          }
213    
214            if (last_aid != article_block_last_aid())
215            {
216                    printf("last_aid != %d\n", article_block_last_aid());
217            }
218    
219            if (article_block_article_count() != section_count * BBS_article_limit_per_section)
220            {
221                    printf("article_block_article_count() error %d != %d * %d\n",
222                               article_block_article_count(), section_count, BBS_article_limit_per_section);
223            }
224    
225          last_aid = 0;          last_aid = 0;
226    
227          for (j = 0; j < BBS_article_limit_per_section; j++)          for (j = 0; j < BBS_article_limit_per_section; j++)
# Line 290  int main(int argc, char *argv[]) Line 302  int main(int argc, char *argv[])
302                          article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count));                          article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count));
303                          article.sid = i * 3 + 1;                          article.sid = i * 3 + 1;
304                          article.cid = article.aid;                          article.cid = article.aid;
305                          article.uid = 1; // TODO: randomize                          article.uid = 1;
306                          article.visible = 1;                          article.visible = 1;
307                          article.excerption = 0;                          article.excerption = 0;
308                          article.ontop = 0;                          article.ontop = 0;
309                          article.lock = 0;                          article.lock = 0;
310                            article.transship = 0;
311    
312                          if (section_list_append_article(p_section[i], &article) < 0)                          if (section_list_append_article(p_section[i], &article) < 0)
313                          {                          {
# Line 747  int main(int argc, char *argv[]) Line 760  int main(int argc, char *argv[])
760                          article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count));                          article.tid = ((article.aid < section_first_aid + group_count) ? 0 : (section_first_aid + j % group_count));
761                          article.sid = i * 3 + 1;                          article.sid = i * 3 + 1;
762                          article.cid = article.aid;                          article.cid = article.aid;
763                          article.uid = 1; // TODO: randomize                          article.uid = 1;
764                          article.visible = 1;                          article.visible = 1;
765                          article.excerption = 0;                          article.excerption = 0;
766                          article.ontop = 0;                          article.ontop = 0;
767                          article.lock = 0;                          article.lock = 0;
768                            article.transship = 0;
769    
770                          if (section_list_append_article(p_section[i], &article) < 0)                          if (section_list_append_article(p_section[i], &article) < 0)
771                          {                          {


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

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