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

Diff of /lbbs/src/menu.c

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

Revision 1.80 by sysadm, Tue Nov 4 13:49:51 2025 UTC Revision 1.84 by sysadm, Wed Nov 5 04:19:21 2025 UTC
# Line 3  Line 3 
3   * menu   * menu
4   *   - configurable user interactive menu feature   *   - configurable user interactive menu feature
5   *   *
6   * Copyright (C) 2004-2025 by Leaflet <leaflet@leafok.com>   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7   */   */
8    
9  #include "bbs.h"  #include "bbs.h"
# Line 24  Line 24 
24  #include <sys/ipc.h>  #include <sys/ipc.h>
25  #include <sys/shm.h>  #include <sys/shm.h>
26    
27  #define MENU_SCREEN_PATH_PREFIX "var/MENU_SCR_"  enum _menu_constant_t
28  #define MENU_CONF_DELIM_WITH_SPACE " ,\t\r\n"  {
29  #define MENU_CONF_DELIM_WITHOUT_SPACE "\r\n"          MENU_SET_RESERVED_LENGTH = sizeof(int16_t) * 4,
30            MENU_SHMGET_RETRY_LIMIT = 10,
31  #define MENU_SET_RESERVED_LENGTH (sizeof(int16_t) * 4)  };
32    
33  #define MENU_SHMGET_RETRY_LIMIT 10  static const char MENU_CONF_DELIM_WITH_SPACE[] = " ,\t\r\n";
34    static const char MENU_CONF_DELIM_WITHOUT_SPACE[] = "\r\n";
35    
36  MENU_SET bbs_menu;  MENU_SET bbs_menu;
37  MENU_SET top10_menu;  MENU_SET top10_menu;
# Line 96  int load_menu(MENU_SET *p_menu_set, cons Line 97  int load_menu(MENU_SET *p_menu_set, cons
97                  key = ftok(conf_file, proj_id + retry_cnt);                  key = ftok(conf_file, proj_id + retry_cnt);
98                  if (key == -1)                  if (key == -1)
99                  {                  {
100                          log_error("ftok(%s %d) error (%d)\n", conf_file, proj_id, errno);                          log_error("ftok(%s %d) error (%d)\n", conf_file, proj_id + retry_cnt, errno);
101                          return -2;                          return -3;
102                  }                  }
103    
104                  p_menu_set->shmid = shmget(key, size, IPC_CREAT | IPC_EXCL | 0600);                  p_menu_set->shmid = shmget(key, size, IPC_CREAT | IPC_EXCL | 0600);
   
105                  if (p_menu_set->shmid == -1)                  if (p_menu_set->shmid == -1)
106                  {                  {
107                          if (errno != EEXIST || retry_cnt + 1 >= MENU_SHMGET_RETRY_LIMIT)                          if (errno != EEXIST || retry_cnt + 1 >= MENU_SHMGET_RETRY_LIMIT)
108                          {                          {
109                                  log_error("shmget(conf_file=%s, size=%d) error (%d) %d times\n",                                  log_error("shmget(conf_file=%s, size=%d) error (%d) %d times\n",
110                                                    conf_file, size, errno, retry_cnt + 1);                                                    conf_file, size, errno, retry_cnt + 1);
111                                  break;                                  return -3;
112                          }                          }
113                          log_error("shmget(conf_file=%s, proj_id=%d, key=0x%x, size=%d) error (%d), retry ...\n",                          log_error("shmget(conf_file=%s, proj_id=%d, key=0x%x, size=%d) error (%d), retry ...\n",
114                                            conf_file, proj_id + retry_cnt, key, size, errno);                                            conf_file, proj_id + retry_cnt, key, size, errno);
# Line 1385  int unload_menu(MENU_SET *p_menu_set) Line 1385  int unload_menu(MENU_SET *p_menu_set)
1385    
1386          detach_menu_shm(p_menu_set);          detach_menu_shm(p_menu_set);
1387    
1388          if (shmctl(shmid, IPC_RMID, NULL) == -1)          if (shmid != 0 && shmctl(shmid, IPC_RMID, NULL) == -1)
1389          {          {
1390                  log_error("shmctl(shmid=%d, IPC_RMID) error (%d)\n", shmid, errno);                  log_error("shmctl(shmid=%d, IPC_RMID) error (%d)\n", shmid, errno);
1391                  return -1;                  return -1;


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

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