/[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.16 by sysadm, Fri May 23 11:05:44 2025 UTC Revision 1.17 by sysadm, Fri May 23 14:04:05 2025 UTC
# Line 21  Line 21 
21  #include <unistd.h>  #include <unistd.h>
22  #include <errno.h>  #include <errno.h>
23    
24    #define ARTICLE_BLOCK_SHM_FILE "~article_block_shm.dat"
25    #define SECTION_LIST_SHM_FILE "~section_list_shm.dat"
26    
27  const char *sname[] = {  const char *sname[] = {
28          "Test",          "Test",
29          "ABCDEFG",          "ABCDEFG",
# Line 56  int main(int argc, char *argv[]) Line 59  int main(int argc, char *argv[])
59          int32_t page;          int32_t page;
60          int32_t offset;          int32_t offset;
61          int affected_count;          int affected_count;
62            FILE *fp;
63    
64          if (log_begin("../log/bbsd.log", "../log/error.log") < 0)          if (log_begin("../log/bbsd.log", "../log/error.log") < 0)
65          {          {
# Line 69  int main(int argc, char *argv[]) Line 73  int main(int argc, char *argv[])
73          // - 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
74          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;
75    
76          if (article_block_init("../conf/menu.conf", block_count) < 0)          if ((fp = fopen(ARTICLE_BLOCK_SHM_FILE, "w")) == NULL)
77            {
78                    log_error("fopen(%s) error\n", ARTICLE_BLOCK_SHM_FILE);
79                    return -1;
80            }
81            fclose(fp);
82    
83            if ((fp = fopen(SECTION_LIST_SHM_FILE, "w")) == NULL)
84          {          {
85                  log_error("section_data_pool_init() error\n");                  log_error("fopen(%s) error\n", SECTION_LIST_SHM_FILE);
86                    return -1;
87            }
88            fclose(fp);
89    
90            if (article_block_init(ARTICLE_BLOCK_SHM_FILE, block_count) < 0)
91            {
92                    log_error("section_data_pool_init(%s, %d) error\n", ARTICLE_BLOCK_SHM_FILE, block_count);
93                    return -2;
94            }
95    
96            if (section_list_pool_init(SECTION_LIST_SHM_FILE) < 0)
97            {
98                    log_error("section_list_pool_init(%s) error\n", SECTION_LIST_SHM_FILE);
99                  return -2;                  return -2;
100          }          }
101    
# Line 669  int main(int argc, char *argv[]) Line 693  int main(int argc, char *argv[])
693          getchar();          getchar();
694    
695          article_block_cleanup();          article_block_cleanup();
696            section_list_pool_cleanup();
697    
698            if (unlink(ARTICLE_BLOCK_SHM_FILE) < 0)
699            {
700                    log_error("unlink(%s) error\n", ARTICLE_BLOCK_SHM_FILE);
701                    return -1;
702            }
703    
704            if (unlink(SECTION_LIST_SHM_FILE) < 0)
705            {
706                    log_error("unlink(%s) error\n", SECTION_LIST_SHM_FILE);
707                    return -1;
708            }
709    
710          log_end();          log_end();
711    


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

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