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

Diff of /lbbs/src/menu_proc.c

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

Revision 1.17 by sysadm, Mon May 19 01:44:49 2025 UTC Revision 1.29 by sysadm, Tue Jun 24 12:32:16 2025 UTC
# Line 14  Line 14 
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
16    
17    #include "article_cache.h"
18    #include "article_view_log.h"
19  #include "bbs.h"  #include "bbs.h"
20  #include "bbs_cmd.h"  #include "bbs_cmd.h"
21  #include "common.h"  #include "common.h"
 #include "log.h"  
22  #include "io.h"  #include "io.h"
23  #include "screen.h"  #include "log.h"
24    #include "login.h"
25  #include "menu.h"  #include "menu.h"
26    #include "section_list_display.h"
27    #include "screen.h"
28    #include "user_priv.h"
29  #include <dlfcn.h>  #include <dlfcn.h>
30  #include <errno.h>  #include <errno.h>
31  #include <signal.h>  #include <signal.h>
32    #include <stdlib.h>
33  #include <string.h>  #include <string.h>
 #include <sys/types.h>  
34  #include <time.h>  #include <time.h>
35  #include <unistd.h>  #include <unistd.h>
36    #include <sys/types.h>
37    
38  int list_section(void *param)  int list_section(void *param)
39  {  {
40          return 0;          section_list_display(param);
41    
42            return REDRAW;
43  }  }
44    
45  int exec_mbem(void *param)  int exec_mbem(void *param)
# Line 82  int exec_mbem(void *param) Line 90  int exec_mbem(void *param)
90          return REDRAW;          return REDRAW;
91  }  }
92    
93  int exitbbs(void *param)  int exit_bbs(void *param)
94  {  {
95          return EXITBBS;          return EXITBBS;
96  }  }
97    
98  int license(void *param)  int license(void *param)
99  {  {
100          display_file_ex(DATA_LICENSE, 1, 1);          display_file(DATA_LICENSE, 0);
101    
102          return REDRAW;          return REDRAW;
103  }  }
104    
105  int copyright(void *param)  int copyright(void *param)
106  {  {
107          display_file_ex(DATA_COPYRIGHT, 1, 1);          display_file(DATA_COPYRIGHT, 1);
108    
109          return REDRAW;          return REDRAW;
110  }  }
111    
112  int reloadbbsmenu(void *param)  int reload_bbs_conf(void *param)
113  {  {
114          clearscr();          clearscr();
115    
# Line 121  int reloadbbsmenu(void *param) Line 129  int reloadbbsmenu(void *param)
129          return REDRAW;          return REDRAW;
130  }  }
131    
132  int shutdownbbs(void *param)  int shutdown_bbs(void *param)
133  {  {
134          log_std("Notify main process to exit\n");          log_common("Notify main process to exit\n");
135    
136          if (kill(getppid(), SIGTERM) < 0)          if (kill(getppid(), SIGTERM) < 0)
137          {          {
# Line 131  int shutdownbbs(void *param) Line 139  int shutdownbbs(void *param)
139          }          }
140    
141          return REDRAW;          return REDRAW;
142    }
143    
144    int favour_section_filter(void *param)
145    {
146            MENU_ITEM *p_menu_item = param;
147    
148            return (is_favor(&BBS_priv, p_menu_item->priv) && checklevel2(&BBS_priv, p_menu_item->level));
149    }
150    
151    static int display_ex_article_key_handler(int *p_key, DISPLAY_CTX *p_ctx)
152    {
153            switch (*p_key)
154            {
155            case 0: // Set msg
156                    snprintf(p_ctx->msg, sizeof(p_ctx->msg),
157                                     "| ·µ»Ø[\033[32m¡û\033[33m,\033[32mESC\033[33m] | "
158                                     "ÒÆ¶¯[\033[32m¡ü\033[33m/\033[32m¡ý\033[33m/\033[32mPgUp\033[33m/\033[32mPgDn\033[33m] | "
159                                     "°ïÖú[\033[32mh\033[33m] |");
160                    break;
161            }
162    
163            return 0;
164    }
165    
166    int view_ex_article(void *param)
167    {
168            ARTICLE_CACHE cache;
169            ARTICLE *p_article;
170            int32_t aid = atoi(param);
171            int ret;
172    
173            (void)ret;
174    
175            p_article = article_block_find_by_aid(aid);
176            if (p_article == NULL)
177            {
178                    log_error("article_block_find_by_aid(%d) error\n", aid);
179                    return NOREDRAW;
180            }
181    
182            if (article_cache_load(&cache, VAR_ARTICLE_CACHE_DIR, p_article) < 0)
183            {
184                    log_error("article_cache_load(aid=%d, cid=%d) error\n", p_article->aid, p_article->cid);
185                    return NOREDRAW;
186            }
187    
188            if (user_online_update("VIEW_ARTICLE") < 0)
189            {
190                    log_error("user_online_update(VIEW_ARTICLE) error\n");
191            }
192    
193            ret = display_data(cache.p_data, cache.line_total, cache.line_offsets, 0,
194                                               display_ex_article_key_handler, DATA_READ_HELP);
195    
196            if (article_cache_unload(&cache) < 0)
197            {
198                    log_error("article_cache_unload(aid=%d, cid=%d) error\n", p_article->aid, p_article->cid);
199            }
200    
201            // Update article_view_log
202            if (article_view_log_set_viewed(p_article->aid, &BBS_article_view_log) < 0)
203            {
204                    log_error("article_view_log_set_viewed(aid=%d) error\n", p_article->aid);
205            }
206    
207            return REDRAW;
208    }
209    
210    int list_ex_section(void *param)
211    {
212            SECTION_LIST *p_section;
213    
214            p_section = section_list_find_by_name(param);
215            if (p_section == NULL)
216            {
217                    log_error("Section %s not found\n", (const char *)param);
218                    return -1;
219            }
220    
221            if (section_list_ex_dir_display(p_section) < 0)
222            {
223                    log_error("section_list_ex_dir_display(sid=%d) error\n", p_section->sid);
224            }
225    
226            return REDRAW;
227  }  }


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

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