/[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.8 by sysadm, Sat May 7 09:28:12 2005 UTC Revision 1.36 by sysadm, Thu Nov 20 03:22:35 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /* SPDX-License-Identifier: GPL-3.0-or-later */
2                            menu.h  -  description  /*
3                               -------------------   * menu
4      begin                : Wed Mar 16 2004   *   - configurable user interactive menu feature
5      copyright            : (C) 2005 by Leaflet   *
6      email                : leaflet@leafok.com   * 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 2 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  #define MAX_MENUITEM_LENGTH             50  #include "bbs_cmd.h"
13  #define MAX_MENUITEMS                   30  #include "common.h"
14  #define MAX_MENUNAME_LENGTH             256  #include "trie_dict.h"
15  #define MAX_MENUACTION_LENGTH           20  #include <stdint.h>
 #define MAX_MENUTITLE_LENGTH            50  
 #define MAX_MENUS                       256  
 #define MAX_MENU_DEPTH                  50  
16    
17  struct _menu_item  enum menu_constant_t
18  {  {
19    int row, col, r_row, r_col;          MAX_MENU_NAME_LENGTH = 30,
20    char action[MAX_MENUACTION_LENGTH];          MAX_ITEMS_PER_MENU = 256,
21    int submenu;          MAX_MENUITEM_NAME_LENGTH = 256,
22    int priv, level, display;          MAX_MENUITEM_TEXT_LENGTH = 200,
23    char name[MAX_MENUNAME_LENGTH];          MAX_MENUITEM_ACTION_LENGTH = 30,
24    char text[MAX_MENUITEM_LENGTH];          MAX_MENUTITLE_TEXT_LENGTH = 100,
25            MAX_MENU_SCR_NAME_LENGTH = 20,
26            MAX_MENU_SCR_BUF_LENGTH = 2000,
27            MAX_MENUS = 256,
28            MAX_MENUITEMS = 5120,
29            MAX_MENU_DEPTH = 50,
30  };  };
 typedef struct _menu_item MENU_ITEM;  
31    
32  struct _menu_title  typedef uint64_t MENU_ID;
33    typedef uint64_t MENU_ITEM_ID;
34    typedef uint64_t MENU_SCREEN_ID;
35    
36    struct menu_item_t
37  {  {
38    int row, col, show;          int16_t row, col;
39    char text[MAX_MENUTITLE_LENGTH];          char action[MAX_MENUITEM_ACTION_LENGTH];
40            MENU_ID action_menu_id;
41            bbs_cmd_handler action_cmd_handler;
42            int8_t submenu;
43            int priv, level;
44            char name[MAX_MENUITEM_NAME_LENGTH];
45            char text[MAX_MENUITEM_TEXT_LENGTH];
46  };  };
47  typedef struct _menu_title MENU_TITLE;  typedef struct menu_item_t MENU_ITEM;
48    
49  struct _menu_screen  struct menu_title_t
50  {  {
51    int row, col, show;          int16_t row, col;
52    char filename[256];          int8_t show;
53            char text[MAX_MENUTITLE_TEXT_LENGTH];
54  };  };
55  typedef struct _menu_screen MENU_SCREEN;  typedef struct menu_title_t MENU_TITLE;
56    
57  struct _menu  struct menu_screen_t
58  {  {
59    char name[MAX_MENUNAME_LENGTH];          char name[MAX_MENU_SCR_NAME_LENGTH];
60    MENU_TITLE title;          int64_t buf_offset;
61    MENU_SCREEN screen;          int64_t buf_length;
   MENU_ITEM *items[MAX_MENUITEMS];  
   int item_count, item_cur_pos;  
62  };  };
63  typedef struct _menu MENU;  typedef struct menu_screen_t MENU_SCREEN;
64    
65  struct _menu_set  struct menu_t
66  {  {
67    char conf_file[256];          char name[MAX_MENU_NAME_LENGTH];
68    MENU *p_menu[MAX_MENUS];          MENU_TITLE title;
69    MENU *p_menu_select[MAX_MENU_DEPTH];          char screen_name[MAX_MENU_SCR_NAME_LENGTH];
70    int menu_count;          MENU_SCREEN_ID screen_id;
71    int menu_select_depth;          int8_t screen_show;
72            int16_t screen_row, screen_col;
73            MENU_ITEM_ID items[MAX_ITEMS_PER_MENU];
74            int16_t item_count;
75            int16_t page_row, page_col;
76            int16_t page_item_limit;
77            int8_t use_filter;
78            bbs_cmd_handler filter_handler;
79  };  };
80  typedef struct _menu_set MENU_SET;  typedef struct menu_t MENU;
81    
82    struct menu_set_t
83    {
84            char shm_name[FILE_NAME_LEN];
85            size_t shm_size;
86            void *p_reserved;
87            void *p_menu_pool;
88            void *p_menu_item_pool;
89            void *p_menu_screen_pool;
90            char *p_menu_screen_buf;
91            char *p_menu_screen_buf_free;
92            int16_t menu_count;
93            int16_t menu_item_count;
94            int16_t menu_screen_count;
95            TRIE_NODE *p_menu_name_dict;
96            TRIE_NODE *p_menu_screen_dict;
97            MENU_ID menu_id_path[MAX_MENU_DEPTH];
98            int16_t menu_item_pos[MAX_MENU_DEPTH];
99            int16_t choose_step;
100            int8_t menu_item_display[MAX_ITEMS_PER_MENU];
101            int16_t menu_item_r_row[MAX_ITEMS_PER_MENU];
102            int16_t menu_item_r_col[MAX_ITEMS_PER_MENU];
103            int16_t menu_item_page_id[MAX_ITEMS_PER_MENU];
104            int8_t allow_exit;
105    };
106    typedef struct menu_set_t MENU_SET;
107    
108  extern MENU_SET 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);
112    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);
116    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);
120    extern int display_menu(MENU_SET *p_menu_set);
121    
122    inline MENU *get_menu(MENU_SET *p_menu_set, const char *menu_name)
123    {
124            MENU *value = NULL;
125    
126            trie_dict_get(p_menu_set->p_menu_name_dict, menu_name, (int64_t *)&value);
127    
128            return ((MENU *)value);
129    }
130    
131    inline MENU *get_menu_by_id(MENU_SET *p_menu_set, MENU_ID menu_id)
132    {
133            if (menu_id < 0 || menu_id >= p_menu_set->menu_count)
134            {
135                    return NULL;
136            }
137    
138            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)
142    {
143            if (menu_item_id < 0 || menu_item_id >= p_menu_set->menu_item_count)
144            {
145                    return NULL;
146            }
147    
148            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)
152    {
153            if (menu_screen_id < 0 || menu_screen_id >= p_menu_set->menu_screen_count)
154            {
155                    return NULL;
156            }
157    
158  extern int load_menu (MENU_SET * p_menu_set, const char *conf_file);          return (MENU_SCREEN *)((char *)(p_menu_set->p_menu_screen_pool) + sizeof(MENU_ITEM) * menu_screen_id);
159  extern void unload_menu (MENU_SET * p_menu_set);  }
 extern int reload_menu (MENU_SET * p_menu_set);  
 extern int menu_control (MENU_SET * p_menu_set, int key);  
 extern int display_menu (MENU * p_menu);  
 extern MENU *get_menu (MENU_SET * p_menu_set, const char *menu_name);  
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