summaryrefslogtreecommitdiffstats
path: root/src/toptions.c
blob: ed17aa2698f7069612a516a8d7876117ddb089b5 (plain)
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
/*

    File: toptions.c

    Copyright (C) 2008 Christophe GRENIER <grenier@cgsecurity.org>
  
    This software 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 of the License, or
    (at your option) any later version.
  
    This program 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; if not, write the Free Software Foundation, Inc., 51
    Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

 */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
 
#include <stdio.h>
#include "types.h"
#include "common.h"
#include "intrf.h"
#ifdef HAVE_NCURSES
#include "intrfn.h"
#endif
#include "log.h"
#include "toptions.h"

#ifdef HAVE_NCURSES
static void interface_options_ncurses(int *dump_ind, int *align, unsigned int *expert)
{
  unsigned int menu = 3;
  /* ncurses interface */
  while (1)
  {
    int car;
    int real_key;
    struct MenuItem menuOptions[]=
    {
      { 'E',NULL,"Expert mode adds some functionalities"},
      { 'C',NULL,"Align partitions to cylinder or 1MiB boundaries" },
      { 'D',NULL,"Dump essential sectors" },
      { 'Q',"[ Ok ]","Done with changing options"},
      { 0, NULL, NULL }
    };
    menuOptions[0].name=*expert?"Expert mode : Yes":"Expert mode : No";
    menuOptions[1].name=*align?"Align partition: Yes":"No";
    menuOptions[2].name=*dump_ind?"Dump : Yes":"Dump : No";
    aff_copy(stdscr);
    car=wmenuSelect_ext(stdscr, 23, INTER_OPTION_Y, INTER_OPTION_X, menuOptions, 0, "ECDQ", MENU_VERT|MENU_VERT_ARROW2VALID, &menu,&real_key);
    switch(car)
    {
      case 'd':
      case 'D':
	*dump_ind=!*dump_ind;
	break;
      case 'c':
      case 'C':
	*align=!*align;
	break;
      case 'e':
      case 'E':
	*expert=!*expert;
	break;
      case key_ESC:
      case 'q':
      case 'Q':
	return;
    }
  }
}
#endif

void interface_options(int *dump_ind, int *align, unsigned int *expert, char**current_cmd)
{
  if(*current_cmd==NULL)
  {
#ifdef HAVE_NCURSES
    interface_options_ncurses(dump_ind, align, expert);
#endif
  }
  /* write new options to log file */
  log_info("New options :\n");
  log_info(" Dump : %s\n", (*dump_ind?"Yes":"No"));
  log_info(" Align partition: %s\n", (*align?"Yes":"No"));
  log_info(" Expert mode : %s\n", (*expert?"Yes":"No"));
}