summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Makefile.am2
-rw-r--r--src/phrecn.c61
-rw-r--r--src/pnext.h81
3 files changed, 83 insertions, 61 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 578755b..14fccdf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -207,7 +207,7 @@ photorec_C = photorec.c phcfg.c ext2grp.c ext2_dir.c fat_dir.c fatp.c list.c nt
photorec_H = photorec.h phcfg.h dir.c dir.h ext2grp.h ext2p.c ext2p.h ext2_dir.h ext2_inc.h fat_dir.h fatp.h memmem.h ntfs_dir.h ntfsp.h ntfs_inc.h sessionp.h
photorec_ncurses_C = addpart.c askloc.c chgtype.c chgtypen.c geometry.c hiddenn.c intrfn.c nodisk.c parti386n.c partgptn.c partmacn.c partsunn.c partxboxn.c pbanner.c pblocksize.c pdisksel.c pfree_whole.c phrecn.c ppartsel.c
-photorec_ncurses_H = addpart.h askloc.h chgtype.h chgtypen.h geometry.h hiddenn.h intrfn.h nodisk.h parti386n.h partgptn.h partmacn.h partsunn.h partxboxn.h pblocksize.h pdisksel.h pfree_whole.h phrecn.h ppartsel.h
+photorec_ncurses_H = addpart.h askloc.h chgtype.h chgtypen.h geometry.h hiddenn.h intrfn.h nodisk.h parti386n.h partgptn.h partmacn.h partsunn.h partxboxn.h pblocksize.h pdisksel.h pfree_whole.h pnext.h phrecn.h ppartsel.h
photorec_SOURCES = phmain.c $(photorec_C) $(photorec_H) $(photorec_ncurses_C) $(photorec_ncurses_H) $(file_C) $(file_H) $(base_C) $(base_H) $(fs_C) $(fs_H) $(ICON_PHOTOREC)
diff --git a/src/phrecn.c b/src/phrecn.c
index 60daf57..c7d1a51 100644
--- a/src/phrecn.c
+++ b/src/phrecn.c
@@ -69,9 +69,9 @@
#include "phcfg.h"
#include "pblocksize.h"
#include "askloc.h"
+#include "pnext.h"
/* #define DEBUG */
-/* #define DEBUG_GET_NEXT_SECTOR */
/* #define DEBUG_BF */
#define READ_SIZE 1024*512
@@ -116,58 +116,6 @@ static inline int ind_block(const unsigned char *buffer, const unsigned int bloc
return 1; /* Ok: ind_block points to non-fragmented block */
}
-static
-#ifndef DEBUG_GET_NEXT_SECTOR
-inline
-#endif
-void get_next_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset)
-{
-#ifdef DEBUG_GET_NEXT_SECTOR
- log_trace(" get_next_header %llu (%llu-%llu)\n",
- (unsigned long long)((*offset)/512),
- (unsigned long long)((*current_search_space)->start/512),
- (unsigned long long)((*current_search_space)->end)/512);
-#endif
- if((*current_search_space) != list_search_space)
- *current_search_space=td_list_entry((*current_search_space)->list.next, alloc_data_t, list);
- *offset=(*current_search_space)->start;
-}
-
-static
-#ifndef DEBUG_GET_NEXT_SECTOR
-inline
-#endif
-void get_next_sector(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const unsigned int blocksize)
-{
-#ifdef DEBUG_GET_NEXT_SECTOR
- log_debug(" get_next_sector %llu (%llu-%llu)\n",
- (unsigned long long)((*offset)/512),
- (unsigned long long)((*current_search_space)->start/512),
- (unsigned long long)((*current_search_space)->end)/512);
-#endif
- if((*current_search_space) == list_search_space)
- {
- return ;
- }
-#ifdef DEBUG_GET_NEXT_SECTOR
- if(! ((*current_search_space)->start <= *offset && (*offset)<=(*current_search_space)->end))
- {
- log_critical("BUG: get_next_sector stop everything %llu (%llu-%llu)\n",
- (unsigned long long)((*offset)/512),
- (unsigned long long)((*current_search_space)->start/512),
- (unsigned long long)((*current_search_space)->end/512));
- log_flush();
- bug();
- log_close();
- exit(1);
- }
-#endif
- if((*offset)+blocksize <= (*current_search_space)->end)
- *offset+=blocksize;
- else
- get_next_header(list_search_space, current_search_space, offset);
-}
-
static inline void file_recovery_cpy(file_recovery_t *dst, file_recovery_t *src)
{
memcpy(dst, src, sizeof(*dst));
@@ -1842,10 +1790,3 @@ void interface_file_select(file_enable_t *files_enable, char**current_cmd)
interface_file_select_ncurses(files_enable);
#endif
}
-
-#ifdef DEBUG_GET_NEXT_SECTOR
-void bug(void)
-{
- log_critical("bug\n");
-}
-#endif
diff --git a/src/pnext.h b/src/pnext.h
new file mode 100644
index 0000000..1201c1d
--- /dev/null
+++ b/src/pnext.h
@@ -0,0 +1,81 @@
+/*
+
+ File: pnext.c
+
+ Copyright (C) 2009 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.
+
+ */
+
+/* #define DEBUG_GET_NEXT_SECTOR */
+static
+#ifndef DEBUG_GET_NEXT_SECTOR
+inline
+#endif
+void get_next_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset)
+{
+#ifdef DEBUG_GET_NEXT_SECTOR
+ log_trace(" get_next_header %llu (%llu-%llu)\n",
+ (unsigned long long)((*offset)/512),
+ (unsigned long long)((*current_search_space)->start/512),
+ (unsigned long long)((*current_search_space)->end)/512);
+#endif
+ if((*current_search_space) != list_search_space)
+ *current_search_space=td_list_entry((*current_search_space)->list.next, alloc_data_t, list);
+ *offset=(*current_search_space)->start;
+}
+
+static
+#ifndef DEBUG_GET_NEXT_SECTOR
+inline
+#endif
+void get_next_sector(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset, const unsigned int blocksize)
+{
+#ifdef DEBUG_GET_NEXT_SECTOR
+ log_debug(" get_next_sector %llu (%llu-%llu)\n",
+ (unsigned long long)((*offset)/512),
+ (unsigned long long)((*current_search_space)->start/512),
+ (unsigned long long)((*current_search_space)->end)/512);
+#endif
+ if((*current_search_space) == list_search_space)
+ {
+ return ;
+ }
+#ifdef DEBUG_GET_NEXT_SECTOR
+ if(! ((*current_search_space)->start <= *offset && (*offset)<=(*current_search_space)->end))
+ {
+ log_critical("BUG: get_next_sector stop everything %llu (%llu-%llu)\n",
+ (unsigned long long)((*offset)/512),
+ (unsigned long long)((*current_search_space)->start/512),
+ (unsigned long long)((*current_search_space)->end/512));
+ log_flush();
+ bug();
+ log_close();
+ exit(1);
+ }
+#endif
+ if((*offset)+blocksize <= (*current_search_space)->end)
+ *offset+=blocksize;
+ else
+ get_next_header(list_search_space, current_search_space, offset);
+}
+
+#ifdef DEBUG_GET_NEXT_SECTOR
+void bug(void)
+{
+ log_critical("bug\n");
+}
+#endif