/[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.20 by sysadm, Mon May 19 01:44:49 2025 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2                            menu.h  -  description                                                    menu.h  -  description
3                               -------------------                                                           -------------------
4      begin                : Wed Mar 16 2004          Copyright            : (C) 2004-2025 by Leaflet
5      copyright            : (C) 2005 by Leaflet          Email                : leaflet@leafok.com
     email                : leaflet@leafok.com  
6   ***************************************************************************/   ***************************************************************************/
7    
8  /***************************************************************************  /***************************************************************************
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
12   *   the Free Software Foundation; either version 2 of the License, or     *   *   the Free Software Foundation; either version 3 of the License, or     *
13   *   (at your option) any later version.                                   *   *   (at your option) any later version.                                   *
14   *                                                                         *   *                                                                         *
15   ***************************************************************************/   ***************************************************************************/
# Line 18  Line 17 
17  #ifndef _MENU_H_  #ifndef _MENU_H_
18  #define _MENU_H_  #define _MENU_H_
19    
20  #define MAX_MENUITEM_LENGTH             50  #include "common.h"
21  #define MAX_MENUITEMS                   30  #include "trie_dict.h"
22  #define MAX_MENUNAME_LENGTH             256  #include "bbs_cmd.h"
23  #define MAX_MENUACTION_LENGTH           20  #include <stdint.h>
24  #define MAX_MENUTITLE_LENGTH            50  #include <sys/shm.h>
25  #define MAX_MENUS                       256  
26  #define MAX_MENU_DEPTH                  50  #define MAX_MENU_NAME_LENGTH 30
27    #define MAX_ITEMS_PER_MENU 30
28  struct _menu_item  #define MAX_MENUITEM_NAME_LENGTH 256
29  {  #define MAX_MENUITEM_TEXT_LENGTH 100
30    int row, col, r_row, r_col;  #define MAX_MENUITEM_ACTION_LENGTH 30
31    char action[MAX_MENUACTION_LENGTH];  #define MAX_MENUTITLE_TEXT_LENGTH 50
32    int submenu;  #define MAX_MENU_SCR_NAME_LENGTH 20
33    int priv, level, display;  #define MAX_MENU_SCR_BUF_LENGTH 2000
34    char name[MAX_MENUNAME_LENGTH];  #define MAX_MENUS 256
35    char text[MAX_MENUITEM_LENGTH];  #define MAX_MENUITEMS 5120
36    #define MAX_MENU_DEPTH 50
37    
38    typedef uint64_t MENU_ID;
39    typedef uint64_t MENU_ITEM_ID;
40    typedef uint64_t MENU_SCREEN_ID;
41    
42    struct menu_item_t
43    {
44            int16_t row, col;
45            char action[MAX_MENUITEM_ACTION_LENGTH];
46            MENU_ID action_menu_id;
47            bbs_cmd_handler action_cmd_handler;
48            int8_t submenu;
49            int priv, level;
50            char name[MAX_MENUITEM_NAME_LENGTH];
51            char text[MAX_MENUITEM_TEXT_LENGTH];
52  };  };
53  typedef struct _menu_item MENU_ITEM;  typedef struct menu_item_t MENU_ITEM;
54    
55  struct _menu_title  struct menu_title_t
56  {  {
57    int row, col, show;          int16_t row, col;
58    char text[MAX_MENUTITLE_LENGTH];          int8_t show;
59            char text[MAX_MENUTITLE_TEXT_LENGTH];
60  };  };
61  typedef struct _menu_title MENU_TITLE;  typedef struct menu_title_t MENU_TITLE;
62    
63  struct _menu_screen  struct menu_screen_t
64  {  {
65    int row, col, show;          char name[MAX_MENU_SCR_NAME_LENGTH];
66    char filename[256];          int64_t buf_offset;
67            int64_t buf_length;
68  };  };
69  typedef struct _menu_screen MENU_SCREEN;  typedef struct menu_screen_t MENU_SCREEN;
70    
71  struct _menu  struct menu_t
72  {  {
73    char name[MAX_MENUNAME_LENGTH];          char name[MAX_MENU_NAME_LENGTH];
74    MENU_TITLE title;          MENU_TITLE title;
75    MENU_SCREEN screen;          char screen_name[MAX_MENU_SCR_NAME_LENGTH];
76    MENU_ITEM *items[MAX_MENUITEMS];          MENU_SCREEN_ID screen_id;
77    int item_count, item_cur_pos;          int8_t screen_show;
78            int16_t screen_row, screen_col;
79            MENU_ITEM_ID items[MAX_ITEMS_PER_MENU];
80            int16_t item_count;
81  };  };
82  typedef struct _menu MENU;  typedef struct menu_t MENU;
83    
84  struct _menu_set  struct menu_set_t
85  {  {
86    char conf_file[256];          int shmid;
87    MENU *p_menu[MAX_MENUS];          void *p_reserved;
88    MENU *p_menu_select[MAX_MENU_DEPTH];          void *p_menu_pool;
89    int menu_count;          void *p_menu_item_pool;
90    int menu_select_depth;          void *p_menu_screen_pool;
91            char *p_menu_screen_buf;
92            char *p_menu_screen_buf_free;
93            int16_t menu_count;
94            int16_t menu_item_count;
95            int16_t menu_screen_count;
96            TRIE_NODE *p_menu_name_dict;
97            TRIE_NODE *p_menu_screen_dict;
98            MENU_ID menu_id_path[MAX_MENU_DEPTH];
99            int16_t menu_item_pos[MAX_MENU_DEPTH];
100            int16_t choose_step;
101            int8_t menu_item_display[MAX_ITEMS_PER_MENU];
102            int16_t menu_item_r_row[MAX_ITEMS_PER_MENU];
103            int16_t menu_item_r_col[MAX_ITEMS_PER_MENU];
104  };  };
105  typedef struct _menu_set MENU_SET;  typedef struct menu_set_t MENU_SET;
106    
107    extern MENU_SET *p_bbs_menu;
108    
109    extern int load_menu(MENU_SET *p_menu_set, const char *conf_file);
110    extern int unload_menu(MENU_SET *p_menu_set);
111    
112    extern int load_menu_shm(MENU_SET *p_menu_set);
113    extern int unload_menu_shm(MENU_SET *p_menu_set);
114    
115    extern int menu_control(MENU_SET *p_menu_set, int key);
116    extern int display_menu(MENU_SET *p_menu_set);
117    
118    inline MENU *get_menu(MENU_SET *p_menu_set, const char *menu_name)
119    {
120            MENU *value = NULL;
121    
122            trie_dict_get(p_menu_set->p_menu_name_dict, menu_name, (int64_t *)&value);
123    
124  extern MENU_SET bbs_menu;          return ((MENU *)value);
125    }
126    
127    inline MENU *get_menu_by_id(MENU_SET *p_menu_set, MENU_ID menu_id)
128    {
129            if (menu_id < 0 || menu_id >= p_menu_set->menu_count)
130            {
131                    return NULL;
132            }
133    
134            return (p_menu_set->p_menu_pool + sizeof(MENU) * menu_id);
135    }
136    
137    inline MENU_ITEM *get_menu_item_by_id(MENU_SET *p_menu_set, MENU_ITEM_ID menu_item_id)
138    {
139            if (menu_item_id < 0 || menu_item_id >= p_menu_set->menu_item_count)
140            {
141                    return NULL;
142            }
143    
144            return (p_menu_set->p_menu_item_pool + sizeof(MENU_ITEM) * menu_item_id);
145    }
146    
147    inline MENU_SCREEN *get_menu_screen_by_id(MENU_SET *p_menu_set, MENU_SCREEN_ID menu_screen_id)
148    {
149            if (menu_screen_id < 0 || menu_screen_id >= p_menu_set->menu_screen_count)
150            {
151                    return NULL;
152            }
153    
154  extern int load_menu (MENU_SET * p_menu_set, const char *conf_file);          return (p_menu_set->p_menu_screen_pool + sizeof(MENU_ITEM) * menu_screen_id);
155  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);  
156    
157  #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