| 1 |
sysadm |
1.3 |
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
| 2 |
|
|
/*
|
| 3 |
|
|
* article_favor
|
| 4 |
|
|
* - data model and basic operations of user favorite articles
|
| 5 |
|
|
*
|
| 6 |
sysadm |
1.4 |
* Copyright (C) 2004-2025 Leaflet <leaflet@leafok.com>
|
| 7 |
sysadm |
1.3 |
*/
|
| 8 |
sysadm |
1.1 |
|
| 9 |
|
|
#ifndef _ARTICLE_FAVOR_H_
|
| 10 |
|
|
#define _ARTICLE_FAVOR_H_
|
| 11 |
|
|
|
| 12 |
|
|
#include "section_list.h"
|
| 13 |
|
|
#include <stdint.h>
|
| 14 |
|
|
|
| 15 |
sysadm |
1.5 |
enum article_favor_constant_t
|
| 16 |
|
|
{
|
| 17 |
|
|
MAX_FAVOR_AID_BASE_CNT = 10000,
|
| 18 |
|
|
MAX_FAVOR_AID_INC_CNT = 1000,
|
| 19 |
|
|
};
|
| 20 |
sysadm |
1.1 |
|
| 21 |
|
|
struct article_favor_t
|
| 22 |
|
|
{
|
| 23 |
|
|
int uid;
|
| 24 |
sysadm |
1.2 |
int32_t aid_base[MAX_FAVOR_AID_BASE_CNT];
|
| 25 |
sysadm |
1.1 |
int aid_base_cnt;
|
| 26 |
|
|
int32_t aid_inc[MAX_FAVOR_AID_INC_CNT];
|
| 27 |
|
|
int aid_inc_cnt;
|
| 28 |
|
|
};
|
| 29 |
|
|
typedef struct article_favor_t ARTICLE_FAVOR;
|
| 30 |
|
|
|
| 31 |
|
|
extern ARTICLE_FAVOR BBS_article_favor;
|
| 32 |
|
|
|
| 33 |
|
|
// Load baseline article favorite from DB
|
| 34 |
|
|
extern int article_favor_load(int uid, ARTICLE_FAVOR *p_favor, int keep_inc);
|
| 35 |
|
|
// Clear data
|
| 36 |
|
|
extern int article_favor_unload(ARTICLE_FAVOR *p_favor);
|
| 37 |
|
|
// Save incremental article favorite to DB
|
| 38 |
|
|
extern int article_favor_save_inc(const ARTICLE_FAVOR *p_favor);
|
| 39 |
|
|
// Merge incremental article favorite to baseline, without DB read / write
|
| 40 |
|
|
extern int article_favor_merge_inc(ARTICLE_FAVOR *p_favor);
|
| 41 |
|
|
|
| 42 |
|
|
// Check if specific article was set as favorite
|
| 43 |
|
|
extern int article_favor_check(int32_t aid, const ARTICLE_FAVOR *p_favor);
|
| 44 |
|
|
// Set specific article as favorite
|
| 45 |
|
|
extern int article_favor_set(int32_t aid, ARTICLE_FAVOR *p_favor, int state);
|
| 46 |
|
|
|
| 47 |
sysadm |
1.6 |
extern int query_favor_articles(ARTICLE_FAVOR *p_favor, int page_id, const ARTICLE **p_articles,
|
| 48 |
sysadm |
1.1 |
char p_snames[][BBS_section_name_max_len + 1], int *p_article_count, int *p_page_count);
|
| 49 |
|
|
|
| 50 |
|
|
#endif //_ARTICLE_FAVOR_H_
|