/[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.4 by sysadm, Sat Mar 19 14:44:21 2005 UTC Revision 1.17 by sysadm, Thu May 15 06:24:11 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   ***************************************************************************/   ***************************************************************************/
16    
17  #define MAX_MENUITEM_LENGTH             50  #ifndef _MENU_H_
18  #define MAX_MENUITEMS                   30  #define _MENU_H_
 #define MAX_MENUNAME_LENGTH             20  
 #define MAX_MENUACTION_LENGTH           20  
 #define MAX_MENUTITLE_LENGTH            50  
 #define MAX_MENUS                       256  
 #define MAX_MENU_DEPTH                  50  
19    
20  struct _menu_item {  #include "common.h"
21          int row, col, r_row, r_col;  #include "trie_dict.h"
22    #include <stdint.h>
23    #include <sys/shm.h>
24    
25    #define MAX_MENUITEM_LENGTH 50
26    #define MAX_ITEMS_PER_MENU 30
27    #define MAX_MENUNAME_LENGTH 256
28    #define MAX_MENUACTION_LENGTH 20
29    #define MAX_MENUTITLE_LENGTH 50
30    #define MAX_MENU_SCR_NAME_LENGTH 20
31    #define MAX_MENU_SCR_BUF_LENGTH 2000
32    #define MAX_MENUS 256
33    #define MAX_MENUITEMS 5120
34    #define MAX_MENU_DEPTH 50
35    
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;
43          char action[MAX_MENUACTION_LENGTH];          char action[MAX_MENUACTION_LENGTH];
44          int submenu;          MENU_ID action_menu_id;
45          int priv, display;          int8_t submenu;
46            int priv, level;
47          char name[MAX_MENUNAME_LENGTH];          char name[MAX_MENUNAME_LENGTH];
48          char text[MAX_MENUITEM_LENGTH];          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          int row, col;  {
54            int16_t row, col;
55            int8_t show;
56          char text[MAX_MENUTITLE_LENGTH];          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          int row, col;  {
62          char filename[256];          char name[MAX_MENU_SCR_NAME_LENGTH];
63            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          MENU *p_menu[MAX_MENUS];  {
82          MENU *p_menu_select[MAX_MENU_DEPTH];          int shmid;
83          int menu_count;          void *p_reserved;
84          int menu_select_depth;          void *p_menu_pool;
85            void *p_menu_item_pool;
86            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            int8_t menu_item_display[MAX_ITEMS_PER_MENU];
98            int16_t menu_item_r_row[MAX_ITEMS_PER_MENU];
99            int16_t menu_item_r_col[MAX_ITEMS_PER_MENU];
100  };  };
101  typedef struct _menu_set MENU_SET;  typedef struct menu_set_t MENU_SET;
           
 extern MENU_SET bbs_menu;  
102    
103  const char *  extern MENU_SET *p_bbs_menu;
 menu_control (MENU_SET * p_menu_set, int key);  
104    
105  int  extern int load_menu(MENU_SET *p_menu_set, const char *conf_file);
106  display_menu (MENU * p_menu);  extern int unload_menu(MENU_SET *p_menu_set);
107    
108  MENU *  extern int load_menu_shm(MENU_SET *p_menu_set);
109  get_menu (MENU_SET * p_menu_set, const char * menu_name);  extern int unload_menu_shm(MENU_SET *p_menu_set);
110    
111    extern int menu_control(MENU_SET *p_menu_set, int key);
112    extern int display_menu(MENU_SET *p_menu_set);
113    
114    inline MENU *get_menu(MENU_SET *p_menu_set, const char *menu_name)
115    {
116            MENU *value = NULL;
117    
118            trie_dict_get(p_menu_set->p_menu_name_dict, menu_name, (int64_t *)&value);
119    
120            return ((MENU *)value);
121    }
122    
123    inline MENU *get_menu_by_id(MENU_SET *p_menu_set, MENU_ID menu_id)
124    {
125            if (menu_id < 0 || menu_id >= p_menu_set->menu_count)
126            {
127                    return NULL;
128            }
129    
130            return (p_menu_set->p_menu_pool + sizeof(MENU) * menu_id);
131    }
132    
133    inline MENU_ITEM *get_menu_item_by_id(MENU_SET *p_menu_set, MENU_ITEM_ID menu_item_id)
134    {
135            if (menu_item_id < 0 || menu_item_id >= p_menu_set->menu_item_count)
136            {
137                    return NULL;
138            }
139    
140            return (p_menu_set->p_menu_item_pool + sizeof(MENU_ITEM) * menu_item_id);
141    }
142    
143    inline MENU_SCREEN *get_menu_screen_by_id(MENU_SET *p_menu_set, MENU_SCREEN_ID menu_screen_id)
144    {
145            if (menu_screen_id < 0 || menu_screen_id >= p_menu_set->menu_screen_count)
146            {
147                    return NULL;
148            }
149    
150            return (p_menu_set->p_menu_screen_pool + sizeof(MENU_ITEM) * menu_screen_id);
151    }
152    
153    #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