/[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.16 by sysadm, Thu May 15 05:14:57 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 <stdint.h>
23  #define MAX_MENUACTION_LENGTH           20  #include <sys/shm.h>
24  #define MAX_MENUTITLE_LENGTH            50  
25  #define MAX_MENUS                       256  #define MAX_MENUITEM_LENGTH 50
26  #define MAX_MENU_DEPTH                  50  #define MAX_ITEMS_PER_MENU 30
27    #define MAX_MENUNAME_LENGTH 256
28  struct _menu_item  #define MAX_MENUACTION_LENGTH 20
29  {  #define MAX_MENUTITLE_LENGTH 50
30    int row, col, r_row, r_col;  #define MAX_MENU_SCR_NAME_LENGTH 20
31    char action[MAX_MENUACTION_LENGTH];  #define MAX_MENU_SCR_BUF_LENGTH 2000
32    int submenu;  #define MAX_MENUS 256
33    int priv, level, display;  #define MAX_MENUITEMS 5120
34    char name[MAX_MENUNAME_LENGTH];  #define MAX_MENU_DEPTH 50
35    char text[MAX_MENUITEM_LENGTH];  
36    typedef uint64_t MENU_ID;
37    typedef uint64_t MENU_ITEM_ID;
38    typedef uint64_t MENU_SCREEN_ID;
39    
40    struct menu_item_t
41    {
42            int16_t row, col, r_row, r_col;
43            char action[MAX_MENUACTION_LENGTH];
44            MENU_ID action_menu_id;
45            int8_t submenu, display;
46            int priv, level;
47            char name[MAX_MENUNAME_LENGTH];
48            char text[MAX_MENUITEM_LENGTH];
49  };  };
50  typedef struct _menu_item MENU_ITEM;  typedef struct menu_item_t MENU_ITEM;
51    
52  struct _menu_title  struct menu_title_t
53  {  {
54    int row, col, show;          int16_t row, col;
55    char text[MAX_MENUTITLE_LENGTH];          int8_t show;
56            char text[MAX_MENUTITLE_LENGTH];
57  };  };
58  typedef struct _menu_title MENU_TITLE;  typedef struct menu_title_t MENU_TITLE;
59    
60  struct _menu_screen  struct menu_screen_t
61  {  {
62    int row, col, show;          char name[MAX_MENU_SCR_NAME_LENGTH];
63    char filename[256];          int64_t buf_offset;
64            int64_t buf_length;
65  };  };
66  typedef struct _menu_screen MENU_SCREEN;  typedef struct menu_screen_t MENU_SCREEN;
67    
68  struct _menu  struct menu_t
69  {  {
70    char name[MAX_MENUNAME_LENGTH];          char name[MAX_MENUNAME_LENGTH];
71    MENU_TITLE title;          MENU_TITLE title;
72    MENU_SCREEN screen;          MENU_SCREEN_ID screen_id;
73    MENU_ITEM *items[MAX_MENUITEMS];          int8_t screen_show;
74    int item_count, item_cur_pos;          int16_t screen_row, screen_col;
75            MENU_ITEM_ID items[MAX_ITEMS_PER_MENU];
76            int16_t item_count;
77  };  };
78  typedef struct _menu MENU;  typedef struct menu_t MENU;
79    
80  struct _menu_set  struct menu_set_t
81  {  {
82    char conf_file[256];          int shmid;
83    MENU *p_menu[MAX_MENUS];          void *p_reserved;
84    MENU *p_menu_select[MAX_MENU_DEPTH];          void *p_menu_pool;
85    int menu_count;          void *p_menu_item_pool;
86    int menu_select_depth;          void *p_menu_screen_pool;
87            char *p_menu_screen_buf;
88            char *p_menu_screen_buf_free;
89            int16_t menu_count;
90            int16_t menu_item_count;
91            int16_t menu_screen_count;
92            TRIE_NODE *p_menu_name_dict;
93            TRIE_NODE *p_menu_screen_dict;
94            MENU_ID menu_id_path[MAX_MENU_DEPTH];
95            int16_t menu_item_pos[MAX_MENU_DEPTH];
96            int16_t choose_step;
97  };  };
98  typedef struct _menu_set MENU_SET;  typedef struct menu_set_t MENU_SET;
99    
100    extern MENU_SET *p_bbs_menu;
101    
102    extern int load_menu(MENU_SET *p_menu_set, const char *conf_file);
103    extern int unload_menu(MENU_SET *p_menu_set);
104    
105    extern int load_menu_shm(MENU_SET *p_menu_set);
106    extern int unload_menu_shm(MENU_SET *p_menu_set);
107    
108    extern int menu_control(MENU_SET *p_menu_set, int key);
109    extern int display_menu(MENU_SET *p_menu_set);
110    
111    inline MENU *get_menu(MENU_SET *p_menu_set, const char *menu_name)
112    {
113            MENU *value = NULL;
114    
115            trie_dict_get(p_menu_set->p_menu_name_dict, menu_name, (int64_t *)&value);
116    
117  extern MENU_SET bbs_menu;          return ((MENU *)value);
118    }
119    
120    inline MENU *get_menu_by_id(MENU_SET *p_menu_set, MENU_ID menu_id)
121    {
122            if (menu_id < 0 || menu_id >= p_menu_set->menu_count)
123            {
124                    return NULL;
125            }
126    
127            return (p_menu_set->p_menu_pool + sizeof(MENU) * menu_id);
128    }
129    
130    inline MENU_ITEM *get_menu_item_by_id(MENU_SET *p_menu_set, MENU_ITEM_ID menu_item_id)
131    {
132            if (menu_item_id < 0 || menu_item_id >= p_menu_set->menu_item_count)
133            {
134                    return NULL;
135            }
136    
137            return (p_menu_set->p_menu_item_pool + sizeof(MENU_ITEM) * menu_item_id);
138    }
139    
140    inline MENU_SCREEN *get_menu_screen_by_id(MENU_SET *p_menu_set, MENU_SCREEN_ID menu_screen_id)
141    {
142            if (menu_screen_id < 0 || menu_screen_id >= p_menu_set->menu_screen_count)
143            {
144                    return NULL;
145            }
146    
147  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);
148  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);  
149    
150  #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