| 1 |
/***************************************************************************
|
| 2 |
section_list.h - description
|
| 3 |
-------------------
|
| 4 |
Copyright : (C) 2004-2025 by Leaflet
|
| 5 |
Email : leaflet@leafok.com
|
| 6 |
***************************************************************************/
|
| 7 |
|
| 8 |
/***************************************************************************
|
| 9 |
* *
|
| 10 |
* This program is free software; you can redistribute it and/or modify *
|
| 11 |
* it under the terms of the GNU General Public License as published by *
|
| 12 |
* the Free Software Foundation; either version 3 of the License, or *
|
| 13 |
* (at your option) any later version. *
|
| 14 |
* *
|
| 15 |
***************************************************************************/
|
| 16 |
|
| 17 |
#include "common.h"
|
| 18 |
#include "bbs.h"
|
| 19 |
|
| 20 |
#define BBS_article_title_max_len 80
|
| 21 |
|
| 22 |
// Limit of articles (including those marked as deleted) per section = BBS_article_limit_per_block * BBS_article_block_limit_per_section
|
| 23 |
#define BBS_article_limit_per_block 1000
|
| 24 |
#define BBS_article_block_limit_per_section 50
|
| 25 |
|
| 26 |
struct article_t
|
| 27 |
{
|
| 28 |
int32_t aid;
|
| 29 |
int32_t tid;
|
| 30 |
int32_t cid;
|
| 31 |
int32_t uid;
|
| 32 |
int32_t prior_aid;
|
| 33 |
int32_t next_aid;
|
| 34 |
int8_t visible;
|
| 35 |
int8_t excerption;
|
| 36 |
int8_t ontop;
|
| 37 |
int8_t lock;
|
| 38 |
char username[BBS_username_max_len + 1];
|
| 39 |
char nickname[BBS_nickname_max_len + 1];
|
| 40 |
char title[BBS_article_title_max_len + 1];
|
| 41 |
};
|
| 42 |
typedef struct article_t ARTICLE;
|
| 43 |
|
| 44 |
struct article_block_t
|
| 45 |
{
|
| 46 |
ARTICLE articles[BBS_article_limit_per_block];
|
| 47 |
int32_t article_count;
|
| 48 |
struct article_block_t *p_next_block;
|
| 49 |
};
|
| 50 |
typedef struct article_block_t ARTICLE_BLOCK;
|
| 51 |
|
| 52 |
struct section_data_t
|
| 53 |
{
|
| 54 |
int32_t sid;
|
| 55 |
char sname[BBS_section_name_max_len + 1];
|
| 56 |
char stitle[BBS_section_title_max_len + 1];
|
| 57 |
char master_name[BBS_username_max_len + 1];
|
| 58 |
ARTICLE_BLOCK *p_head_block;
|
| 59 |
ARTICLE_BLOCK *p_tail_block;
|
| 60 |
ARTICLE_BLOCK *p_block[BBS_article_block_limit_per_section];
|
| 61 |
int32_t block_count;
|
| 62 |
int32_t block_head_aid[BBS_article_block_limit_per_section];
|
| 63 |
int32_t article_count;
|
| 64 |
int32_t delete_count;
|
| 65 |
};
|
| 66 |
typedef struct section_data_t SECTION_DATA;
|
| 67 |
|
| 68 |
extern int section_data_pool_init(const char *filename, int article_block_count);
|
| 69 |
extern void section_data_pool_cleanup(void);
|
| 70 |
|
| 71 |
extern SECTION_DATA *section_data_create(const char *sname, const char *stitle, const char *master_name);
|
| 72 |
extern int section_data_free_block(SECTION_DATA *p_section);
|
| 73 |
extern SECTION_DATA *section_data_find_by_name(const char *sname);
|
| 74 |
|
| 75 |
extern int section_data_append_article(SECTION_DATA *p_section, const ARTICLE *p_article);
|
| 76 |
extern ARTICLE *section_data_search_article(SECTION_DATA *p_section, int32_t aid);
|
| 77 |
extern int section_data_mark_del_article(SECTION_DATA *p_section, int32_t aid);
|