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

Diff of /lbbs/src/article_favor.c

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

Revision 1.4 by sysadm, Wed Oct 15 12:02:38 2025 UTC Revision 1.10 by sysadm, Sun Nov 16 00:10:48 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                           article_favor.c  -  description  /*
3                                                           -------------------   * article_favor
4          Copyright            : (C) 2004-2025 by Leaflet   *   - data model and basic operations of user favorite articles
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
8  /***************************************************************************  
9   *                                                                         *  #ifdef HAVE_CONFIG_H
10   *   This program is free software; you can redistribute it and/or modify  *  #include "config.h"
11   *   it under the terms of the GNU General Public License as published by  *  #endif
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
12    
13  #include "article_favor.h"  #include "article_favor.h"
14  #include "common.h"  #include "common.h"
# Line 321  int article_favor_check(int32_t aid, con Line 317  int article_favor_check(int32_t aid, con
317                          mid = (left + right) / 2;                          mid = (left + right) / 2;
318                          if (aid < (i == 0 ? p_favor->aid_base[mid] : p_favor->aid_inc[mid]))                          if (aid < (i == 0 ? p_favor->aid_base[mid] : p_favor->aid_inc[mid]))
319                          {                          {
320                                  right = mid;                                  right = mid - 1;
321                          }                          }
322                          else if (aid > (i == 0 ? p_favor->aid_base[mid] : p_favor->aid_inc[mid]))                          else if (aid > (i == 0 ? p_favor->aid_base[mid] : p_favor->aid_inc[mid]))
323                          {                          {
# Line 372  int article_favor_set(int32_t aid, ARTIC Line 368  int article_favor_set(int32_t aid, ARTIC
368                          mid = (left + right) / 2;                          mid = (left + right) / 2;
369                          if (aid < (i == 0 ? p_favor->aid_base[mid] : p_favor->aid_inc[mid]))                          if (aid < (i == 0 ? p_favor->aid_base[mid] : p_favor->aid_inc[mid]))
370                          {                          {
371                                  right = mid;                                  right = mid - 1;
372                          }                          }
373                          else if (aid > (i == 0 ? p_favor->aid_base[mid] : p_favor->aid_inc[mid]))                          else if (aid > (i == 0 ? p_favor->aid_base[mid] : p_favor->aid_inc[mid]))
374                          {                          {
# Line 473  int query_favor_articles(ARTICLE_FAVOR * Line 469  int query_favor_articles(ARTICLE_FAVOR *
469                  return -2;                  return -2;
470          }          }
471    
472          *p_page_count = p_favor->aid_base_cnt / BBS_article_limit_per_page + (p_favor->aid_base_cnt % BBS_article_limit_per_page == 0 ? 0 : 1);          *p_page_count = (p_favor->aid_base_cnt + BBS_article_limit_per_page - 1) / BBS_article_limit_per_page;
473          *p_article_count = 0;          *p_article_count = 0;
474    
475          if (p_favor->aid_base_cnt == 0)          if (p_favor->aid_base_cnt == 0)
# Line 508  int query_favor_articles(ARTICLE_FAVOR * Line 504  int query_favor_articles(ARTICLE_FAVOR *
504                          return -3;                          return -3;
505                  }                  }
506    
507                  // acquire lock of section                  if (get_section_info(p_section, p_snames[i], NULL, NULL) < 0)
                 if (section_list_rd_lock(p_section) < 0)  
508                  {                  {
509                          log_error("section_list_rd_lock(sid = %d) error\n", p_section->sid);                          log_error("get_section_info(sid=%d) error\n", p_section->sid);
                         return -4;  
                 }  
   
                 memcpy(p_snames[i], p_section->sname, sizeof(p_snames[i]));  
   
                 // release lock of section  
                 if (section_list_rd_unlock(p_section) < 0)  
                 {  
                         log_error("section_list_rd_unlock(sid = %d) error\n", p_section->sid);  
510                          return -4;                          return -4;
511                  }                  }
512          }          }


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

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