/[LeafOK_CVS]/lbbs/include/menu.h
ViewVC logotype

Diff of /lbbs/include/menu.h

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

Revision 1.22 by sysadm, Sun May 25 06:53:29 2025 UTC Revision 1.35 by sysadm, Wed Nov 19 14:47:08 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                                                    menu.h  -  description  /*
3                                                           -------------------   * menu
4          Copyright            : (C) 2004-2025 by Leaflet   *   - configurable user interactive menu feature
5          Email                : leaflet@leafok.com   *
6   ***************************************************************************/   * Copyright (C) 2004-2025  Leaflet <leaflet@leafok.com>
7     */
 /***************************************************************************  
  *                                                                         *  
  *   This program is free software; you can redistribute it and/or modify  *  
  *   it under the terms of the GNU General Public License as published by  *  
  *   the Free Software Foundation; either version 3 of the License, or     *  
  *   (at your option) any later version.                                   *  
  *                                                                         *  
  ***************************************************************************/  
8    
9  #ifndef _MENU_H_  #ifndef _MENU_H_
10  #define _MENU_H_  #define _MENU_H_
11    
12    #include "bbs_cmd.h"
13  #include "common.h"  #include "common.h"
14  #include "trie_dict.h"  #include "trie_dict.h"
 #include "bbs_cmd.h"  
15  #include <stdint.h>  #include <stdint.h>
 #include <sys/shm.h>  
16    
17  #define MAX_MENU_NAME_LENGTH 30  enum menu_constant_t
18  #define MAX_ITEMS_PER_MENU 256  {
19  #define MAX_MENUITEM_NAME_LENGTH 256          MAX_MENU_NAME_LENGTH = 30,
20  #define MAX_MENUITEM_TEXT_LENGTH 100          MAX_ITEMS_PER_MENU = 256,
21  #define MAX_MENUITEM_ACTION_LENGTH 30          MAX_MENUITEM_NAME_LENGTH = 256,
22  #define MAX_MENUTITLE_TEXT_LENGTH 50          MAX_MENUITEM_TEXT_LENGTH = 200,
23  #define MAX_MENU_SCR_NAME_LENGTH 20          MAX_MENUITEM_ACTION_LENGTH = 30,
24  #define MAX_MENU_SCR_BUF_LENGTH 2000          MAX_MENUTITLE_TEXT_LENGTH = 100,
25  #define MAX_MENUS 256          MAX_MENU_SCR_NAME_LENGTH = 20,
26  #define MAX_MENUITEMS 5120          MAX_MENU_SCR_BUF_LENGTH = 2000,
27  #define MAX_MENU_DEPTH 50          MAX_MENUS = 256,
28            MAX_MENUITEMS = 5120,
29            MAX_MENU_DEPTH = 50,
30    };
31    
32  typedef uint64_t MENU_ID;  typedef uint64_t MENU_ID;
33  typedef uint64_t MENU_ITEM_ID;  typedef uint64_t MENU_ITEM_ID;
# Line 80  struct menu_t Line 74  struct menu_t
74          int16_t item_count;          int16_t item_count;
75          int16_t page_row, page_col;          int16_t page_row, page_col;
76          int16_t page_item_limit;          int16_t page_item_limit;
77            int8_t use_filter;
78            bbs_cmd_handler filter_handler;
79  };  };
80  typedef struct menu_t MENU;  typedef struct menu_t MENU;
81    
82  struct menu_set_t  struct menu_set_t
83  {  {
84          int shmid;          char shm_name[FILE_PATH_LEN];
85            size_t shm_size;
86          void *p_reserved;          void *p_reserved;
87          void *p_menu_pool;          void *p_menu_pool;
88          void *p_menu_item_pool;          void *p_menu_item_pool;
# Line 104  struct menu_set_t Line 101  struct menu_set_t
101          int16_t menu_item_r_row[MAX_ITEMS_PER_MENU];          int16_t menu_item_r_row[MAX_ITEMS_PER_MENU];
102          int16_t menu_item_r_col[MAX_ITEMS_PER_MENU];          int16_t menu_item_r_col[MAX_ITEMS_PER_MENU];
103          int16_t menu_item_page_id[MAX_ITEMS_PER_MENU];          int16_t menu_item_page_id[MAX_ITEMS_PER_MENU];
104            int8_t allow_exit;
105  };  };
106  typedef struct menu_set_t MENU_SET;  typedef struct menu_set_t MENU_SET;
107    
108  extern MENU_SET *p_bbs_menu;  extern MENU_SET bbs_menu;
109    extern MENU_SET top10_menu;
110    
111  extern int load_menu(MENU_SET *p_menu_set, const char *conf_file);  extern int load_menu(MENU_SET *p_menu_set, const char *conf_file);
112  extern int unload_menu(MENU_SET *p_menu_set);  extern int unload_menu(MENU_SET *p_menu_set);
113    
114    extern int get_menu_shm_readonly(MENU_SET *p_menu_set);
115  extern int set_menu_shm_readonly(MENU_SET *p_menu_set);  extern int set_menu_shm_readonly(MENU_SET *p_menu_set);
116  extern int detach_menu_shm(MENU_SET *p_menu_set);  extern int detach_menu_shm(MENU_SET *p_menu_set);
117    
118    extern int display_menu_cursor(MENU_SET *p_menu_set, int show);
119  extern int menu_control(MENU_SET *p_menu_set, int key);  extern int menu_control(MENU_SET *p_menu_set, int key);
120  extern int display_menu(MENU_SET *p_menu_set);  extern int display_menu(MENU_SET *p_menu_set);
121    
# Line 134  inline MENU *get_menu_by_id(MENU_SET *p_ Line 135  inline MENU *get_menu_by_id(MENU_SET *p_
135                  return NULL;                  return NULL;
136          }          }
137    
138          return (p_menu_set->p_menu_pool + sizeof(MENU) * menu_id);          return (MENU *)((char *)(p_menu_set->p_menu_pool) + sizeof(MENU) * menu_id);
139  }  }
140    
141  inline MENU_ITEM *get_menu_item_by_id(MENU_SET *p_menu_set, MENU_ITEM_ID menu_item_id)  inline MENU_ITEM *get_menu_item_by_id(MENU_SET *p_menu_set, MENU_ITEM_ID menu_item_id)
# Line 144  inline MENU_ITEM *get_menu_item_by_id(ME Line 145  inline MENU_ITEM *get_menu_item_by_id(ME
145                  return NULL;                  return NULL;
146          }          }
147    
148          return (p_menu_set->p_menu_item_pool + sizeof(MENU_ITEM) * menu_item_id);          return (MENU_ITEM *)((char *)(p_menu_set->p_menu_item_pool) + sizeof(MENU_ITEM) * menu_item_id);
149  }  }
150    
151  inline MENU_SCREEN *get_menu_screen_by_id(MENU_SET *p_menu_set, MENU_SCREEN_ID menu_screen_id)  inline MENU_SCREEN *get_menu_screen_by_id(MENU_SET *p_menu_set, MENU_SCREEN_ID menu_screen_id)
# Line 154  inline MENU_SCREEN *get_menu_screen_by_i Line 155  inline MENU_SCREEN *get_menu_screen_by_i
155                  return NULL;                  return NULL;
156          }          }
157    
158          return (p_menu_set->p_menu_screen_pool + sizeof(MENU_ITEM) * menu_screen_id);          return (MENU_SCREEN *)((char *)(p_menu_set->p_menu_screen_pool) + sizeof(MENU_ITEM) * menu_screen_id);
159  }  }
160    
161  #endif //_MENU_H_  #endif //_MENU_H_


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

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