summaryrefslogtreecommitdiffstats
path: root/src/pfree_whole.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2008-08-25 23:15:17 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2008-08-25 23:15:17 +0200
commitd5d0a9a74f20ab8288f81ec96be48636dd6e0686 (patch)
treed9ca34d754825448472b3670afaef7a8d43f38e6 /src/pfree_whole.c
parentc943ebd716ad2f71d2f73abc821e266be552a36f (diff)
Split the interface in several files, part 2
Text interface needs 24 lines instead of 25
Diffstat (limited to 'src/pfree_whole.c')
-rw-r--r--src/pfree_whole.c134
1 files changed, 134 insertions, 0 deletions
diff --git a/src/pfree_whole.c b/src/pfree_whole.c
new file mode 100644
index 0000000..cb22e0e
--- /dev/null
+++ b/src/pfree_whole.c
@@ -0,0 +1,134 @@
+/*
+
+ File: pfree_whole.c
+
+ Copyright (C) 1998-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 "types.h"
+#include "common.h"
+#include "intrf.h"
+#ifdef HAVE_NCURSES
+#include "intrfn.h"
+#else
+#include <stdio.h>
+#endif
+#include "log.h"
+#include "pfree_whole.h"
+
+#ifdef HAVE_NCURSES
+int ask_mode_ext2(const disk_t *disk_car, const partition_t *partition, unsigned int *mode_ext2, unsigned int *carve_free_space_only)
+{
+ static const struct MenuItem menuMode[]=
+ {
+ {'E',"ext2/ext3","ext2/ext3/ext4 filesystem"},
+ {'O',"Other","FAT/NTFS/HFS+/ReiserFS/..."},
+ {0,NULL,NULL}
+ };
+ static const struct MenuItem menuFAT16[]=
+ {
+ {'F',"Free", "Scan for files from FAT16 unallocated space only"},
+ {'W',"Whole","Extract files from whole partition"},
+ {0,NULL,NULL}
+ };
+ static const struct MenuItem menuFAT32[]=
+ {
+ {'F',"Free", "Scan for file from FAT32 unallocated space only"},
+ {'W',"Whole","Extract files from whole partition"},
+ {0,NULL,NULL}
+ };
+#ifdef HAVE_LIBNTFS
+ static const struct MenuItem menuNTFS[]=
+ {
+ {'F',"Free", "Scan for file from NTFS unallocated space only"},
+ {'W',"Whole","Extract files from whole partition"},
+ {0,NULL,NULL}
+ };
+#endif
+#ifdef HAVE_LIBEXT2FS
+ static const struct MenuItem menuEXT2[]=
+ {
+ {'F',"Free", "Scan for file from ext2/ext3 unallocated space only"},
+ {'W',"Whole","Extract files from whole partition"},
+ {0,NULL,NULL}
+ };
+#endif
+ const char *options="EO";
+ WINDOW *window;
+ unsigned int menu;
+ int command;
+ if(partition->upart_type==UP_EXT2 ||
+ partition->upart_type==UP_EXT3 ||
+ partition->upart_type==UP_EXT4)
+ menu=0;
+ else
+ menu=1;
+ window=newwin(0,0,0,0); /* full screen */
+ aff_copy(window);
+ wmove(window,4,0);
+ aff_part(window, AFF_PART_ORDER|AFF_PART_STATUS,disk_car,partition);
+ wmove(window,6,0);
+ waddstr(window,"To recover lost files, PhotoRec need to know the filesystem type where the");
+ wmove(window,7,0);
+ waddstr(window,"file were stored:");
+ command = wmenuSelect_ext(window, 23, 8, 0, menuMode, 11,
+ options, MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
+ *mode_ext2=(command=='E' || command=='e');
+ if(*mode_ext2>0)
+ {
+ log_info("ext2/ext3/ext4 mode activated.\n");
+ }
+ {
+ menu=0;
+ options="FW";
+ wmove(window,6,0);
+ wclrtoeol(window);
+ wmove(window,7,0);
+ wclrtoeol(window);
+ waddstr(window,"Please choose if all space need to be analysed:");
+ if(partition->upart_type==UP_FAT16)
+ command = wmenuSelect_ext(window, 23, 8, 0, menuFAT16, 11,
+ options, MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
+ else if(partition->upart_type==UP_FAT32)
+ command = wmenuSelect_ext(window, 23, 8, 0, menuFAT32, 11,
+ options, MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
+#ifdef HAVE_LIBNTFS
+ else if(partition->upart_type==UP_NTFS)
+ command = wmenuSelect_ext(window, 23, 8, 0, menuNTFS, 11,
+ options, MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
+#endif
+#ifdef HAVE_LIBEXT2FS
+ else if(partition->upart_type==UP_EXT2 || partition->upart_type==UP_EXT3 || partition->upart_type==UP_EXT4)
+ command = wmenuSelect_ext(window, 23, 8, 0, menuEXT2, 11,
+ options, MENU_VERT | MENU_VERT_WARN | MENU_BUTTON, &menu,NULL);
+#endif
+ else
+ command='W';
+ *carve_free_space_only=(command=='F' || command=='f')?1:0;
+ if(*carve_free_space_only>0)
+ {
+ log_info("Carve free space only.\n");
+ }
+ }
+ delwin(window);
+ return 0;
+}
+#endif