1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/*
* Copyright (c) 2002 Silicon Graphics, Inc.
* All Rights Reserved.
*
* This program 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.
*
* This program is distributed in the hope that it would 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; if not, write the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef CMENU_H
#define CMENU_H
#include "types.h"
#include "mlog.h"
#include "inv_priv.h"
#include "list.h"
/* number of lines for info window */
#define INFO_SIZE 4
#define put_header(m, a) put_line(stdscr, 0, m, A_REVERSE | A_BOLD, a)
#define put_footer(m, a) put_line(stdscr, LINES - 1, m, A_REVERSE | A_BOLD, a)
#define put_error(m) put_line(stdscr, LINES - 1, m, A_REVERSE | A_BOLD, ALIGN_LEFT);\
beep();\
wrefresh(stdscr);\
sleep(2)
#define put_info_header(m) put_line(infowin, 0, m, A_REVERSE|A_BOLD, ALIGN_LEFT)
#define put_info_line(l, m) put_line(infowin, l, m, 0, ALIGN_LEFT)
#define put_option(w, l, t, a) put_line(w, l, t, a, ALIGN_LEFT)
#define clear_line(w, l) wmove(w, l, 0); wclrtoeol(w);
typedef enum {
ALIGN_LEFT,
ALIGN_CENTRE,
ALIGN_RIGHT
} alignment_t;
typedef struct menu_ops_s {
int (*op_delete) (WINDOW *win, node_t *current, node_t *list);
int (*op_undelete) (WINDOW *win, node_t *current, node_t *list);
int (*op_saveexit) (WINDOW *win, node_t *current, node_t *list);
int (*op_select) (WINDOW *win, node_t *current, node_t *list);
int (*op_collapse) (WINDOW *win, node_t *current, node_t *list);
int (*op_expand) (WINDOW *win, node_t *current, node_t *list);
int (*op_collapseall) (WINDOW *win, node_t *current, node_t *list);
int (*op_expandall) (WINDOW *win, node_t *current, node_t *list);
int (*op_highlight) (WINDOW *win, node_t *current, node_t *list);
int (*op_unhighlight) (WINDOW *win, node_t *current, node_t *list);
int (*op_commit) (WINDOW *win, node_t *current, node_t *list);
int (*op_prune) (char *mountpt, uuid_t *uuidp, time32_t prunetime, node_t *node, node_t *list);
} menu_ops_t;
typedef struct {
int key;
char *text;
int (*fn)(WINDOW *win, node_t *current, node_t *list);
} menukey_t;
typedef struct {
invt_seshdr_t *header;
invt_session_t *session;
} stobjsess_t;
typedef struct {
char *name;
int fd;
int nEntries;
char *mapaddr;
invt_counter_t *counter;
invt_entry_t **data;
int numrecords;
} invidx_fileinfo_t;
typedef struct {
char *name;
int fd;
off_t size;
char *mapaddr;
invt_sescounter_t *counter;
void **data;
int numrecords;
} stobj_fileinfo_t;
typedef struct {
char *name;
int fd;
int nEntries;
char *mapaddr;
invt_counter_t *counter;
invt_fstab_t **data;
int numrecords;
} fstab_fileinfo_t;
extern int redraw_screen;
extern int redraw_options;
extern WINDOW *mainmenu;
extern WINDOW *infowin;
/* cmenu.c */
void hitanykey(void);
int put_line(WINDOW *win, int line, char *msg, int attr, alignment_t alignment);
int create_windows(void);
int get_string(WINDOW *win, char *prompt, char *response, int len);
void list_undelete(node_t *current, node_t *list);
int list_delete(node_t *current, node_t *list);
int menu_import(WINDOW *win, node_t *current, node_t *list);
int menu_unhighlight(WINDOW *win, node_t *current, node_t *list);
int menu_expand(WINDOW *win, node_t *current, node_t *list);
int menu_expandall(WINDOW *win, node_t *current, node_t *list);
int menu_collapse(WINDOW *win, node_t *current, node_t *list);
int menu_collapseall(WINDOW *win, node_t *current, node_t *list);
int menu_select(WINDOW *win, node_t *current, node_t *list);
int menu_delete(WINDOW *win, node_t *current, node_t *list);
int menu_undelete(WINDOW *win, node_t *current, node_t *list);
int menu_saveexit(WINDOW *win, node_t *current, node_t *list);
int menu_commit(WINDOW *win, node_t *current, node_t *list);
int menu_quit(WINDOW *win, node_t *current, node_t *list);
/* menu.c */
int menu(WINDOW *win, int line, int col, node_t *list, int keyc, menukey_t *keyv);
node_t *generate_menu(char *inv_path);
#endif /* CMENU_H */
|