// Filename: menu.h // Contents: the menu system object // Author: Greg Shaw // Created: 7/22/93 /* This file 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, or (at your option) any later version. In addition to the permissions in the GNU General Public License, the Free Software Foundation gives you unlimited permission to link the compiled version of this file with other programs, and to distribute those programs without any restriction coming from the use of this file. (The General Public License restrictions do apply in other respects; for example, they cover modification of the file, and distribution when not linked into another program.) This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _MENU_H_ #define _MENU_H_ #include "bbshdr.h" // file that includes everything extern User user; // need this for access level, flags, timelimit, etc. // Structure: Menuitem // Contents: the pertinent information for each menu item. // command type (number) // misc text // access level // access level modifier // flags // flags modifier // Author: Greg Shaw // Created: 7/22/93 typedef struct { int com_type; // command type char key; // hot key char misc[256]; // miscellaneous text int acl; // access level of command char acl_mod; // access level modifier int flags; // flags (32) char flags_mod; // flags modifier } Menuitem; // Object: Menu // Purpose: Encapsulate the menu operations for the BBS. Everything // relating to how the bbs (aka user) operates the menu system // is contained within this object. // Attributes: path - path to menu // 1..n of struct item (see above for item description) // numitems - the number of command items in menu // connected - has connect to chat object been successful? // socknum - the socket to connect to chat object (in step 2) // last_try - the last try (time) to connect to chat object // (10 seconds between attempts minimum) // Methods: open - open a menu file (read commands from file) // run - run the (already read) menu. Return selected command // number // dump - dump contents of menu object to screen (for debugging) // chat_con - attempt to connect to chat object // Author: Greg Shaw // Created: 7/22/93 class Menu:public bbsint // inherited from bbs interface { char *prompt; // command prompt char menu_path[255]; // path to menu char numitems; // number of items in menu char chat_msg[81]; // last chat message time_t user_logon; // time of user logon (for timeleft prompt) Menuitem items[50]; // 50 menu items at this point char connected; // connected to chat object? int socknum; // socket to use when talking to chat object time_t last_try; // last connected attempt - time get_chat_msg(void); // get chat message (if available) public: Menu(); // constructor open_chat(void); // connect to chat object open(char *path); // read commands from menu Menuitem *run(char *path); // run the menu dump(void); // dump contents of menu object valid_char(void); // get char (if available) and check against items can_view(int acl, int flags, char am, char fm); // can user view this item? }; #endif // _MENU_H_