/[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.2 by sysadm, Sat Mar 19 08:23:17 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   ***************************************************************************/   ***************************************************************************/
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  
19    
20  struct _menu_item {  #include "common.h"
21          int col, row;  #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, r_row, r_col;
43          char action[MAX_MENUACTION_LENGTH];          char action[MAX_MENUACTION_LENGTH];
44          int priv;          MENU_ID action_menu_id;
45            int8_t submenu, display;
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 col, row;  {
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 col, row;  {
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          int menu_count;          int shmid;
83            void *p_reserved;
84            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  };  };
98  typedef struct _menu_set MENU_SET;  typedef struct menu_set_t MENU_SET;
99            
100  extern MENU_SET bbs_menu;  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            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            return (p_menu_set->p_menu_screen_pool + sizeof(MENU_ITEM) * menu_screen_id);
148    }
149    
150    #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