summaryrefslogtreecommitdiffstats
path: root/src/tanalyse.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-08-24 13:36:34 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2008-08-24 13:36:34 +0200
commit9a58a494f354766e1bda5ca0f72e0af60f5124de (patch)
treebfabf63ee6684f79b6f724f2cda5de8b5fadbc76 /src/tanalyse.c
parent05241d82968e9ee7195a424091e733b43d776945 (diff)
Split the interface in several files
Initial work to handle 24 lines and more than 25
Diffstat (limited to 'src/tanalyse.c')
-rw-r--r--src/tanalyse.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/src/tanalyse.c b/src/tanalyse.c
new file mode 100644
index 0000000..0b0743e
--- /dev/null
+++ b/src/tanalyse.c
@@ -0,0 +1,115 @@
+/*
+
+ File: tanalyse.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
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#include "types.h"
+#include "common.h"
+#include "lang.h"
+#include "intrf.h"
+#ifdef HAVE_NCURSES
+#include "intrfn.h"
+#else
+#include <stdio.h>
+#endif
+#include "savehdr.h"
+#include "log.h"
+#include "tanalyse.h"
+
+static list_part_t *interface_analyse_ncurses(disk_t *disk_car, const int verbose, const int saveheader, char**current_cmd)
+{
+ list_part_t *list_part;
+ int command;
+#ifdef HAVE_NCURSES
+ struct MenuItem menuAnalyse[]=
+ {
+ { 'P', "Previous",""},
+ { 'N', "Next","" },
+ { 'Q',"Quick Search","Try to locate partition"},
+ { 'B', "Backup","Save current partition list to backup.log file and proceed"},
+ { 0, NULL, NULL }
+ };
+#endif
+ screen_buffer_reset();
+ /* ncurses interface */
+#ifdef HAVE_NCURSES
+ aff_copy(stdscr);
+ wmove(stdscr,4,0);
+ wprintw(stdscr,"%s\n",disk_car->description(disk_car));
+ mvwaddstr(stdscr,5,0,"Checking current partition structure");
+ wrefresh(stdscr);
+#endif
+ list_part=disk_car->arch->read_part(disk_car,verbose,saveheader);
+ log_info("Current partition structure:\n");
+ screen_buffer_to_log();
+#ifdef HAVE_NCURSES
+ wmove(stdscr,5,0);
+ wclrtoeol(stdscr); /* before addstr for BSD compatibility */
+ waddstr(stdscr,"Current partition structure:");
+ wmove(stdscr,6,0);
+ wprintw(stdscr,msg_PART_HEADER_LONG);
+ if(disk_car->arch->msg_part_type!=NULL)
+ mvwaddstr(stdscr,LINES-3,0,disk_car->arch->msg_part_type);
+#endif
+ command='Q';
+ if(*current_cmd!=NULL)
+ {
+ while(*current_cmd[0]==',')
+ (*current_cmd)++;
+ if(strncmp(*current_cmd,"backup",6)==0)
+ {
+ (*current_cmd)+=6;
+ if(list_part!=NULL)
+ command='B';
+ }
+ }
+ else
+ {
+ log_flush();
+#ifdef HAVE_NCURSES
+ command=screen_buffer_display(stdscr,
+ (list_part!=NULL && disk_car->arch->add_partition!=NULL?"QB":"Q"),
+ menuAnalyse);
+#endif
+ }
+ if(command=='B')
+ {
+ log_info("Backup partition structure\n");
+ if(partition_save(disk_car,list_part,verbose)<0)
+ {
+ display_message("Can't create backup.log.\n");
+ }
+ }
+ return list_part;
+}
+
+list_part_t *interface_analyse(disk_t *disk_car, const int verbose, const int saveheader, char**current_cmd)
+{
+ log_info("\nAnalyse ");
+ log_info("%s\n",disk_car->description(disk_car));
+ return interface_analyse_ncurses(disk_car, verbose, saveheader, current_cmd);
+}
+