summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2012-01-27 08:42:14 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2012-01-27 08:42:14 +0100
commitd256adb14719ae0b31890da4bcad312021882022 (patch)
tree9f6e3f91480b32beaf7022b32bc9842a7be5de90
parent9998392d2127737982e10c01a515649328329196 (diff)
move ask_int_ncurses() and ask_string_ncurses() to src/intrfn.c
add a minimalist find in file listing
-rw-r--r--src/dirn.c20
-rw-r--r--src/intrfn.c55
-rw-r--r--src/intrfn.h2
-rw-r--r--src/ntfs_udl.c54
4 files changed, 77 insertions, 54 deletions
diff --git a/src/dirn.c b/src/dirn.c
index 2d33f09..f4c7a1d 100644
--- a/src/dirn.c
+++ b/src/dirn.c
@@ -467,6 +467,26 @@ static long int dir_aff_ncurses(disk_t *disk, const partition_t *partition, dir_
}
}
break;
+ case 'f':
+ {
+ const char *needle=ask_string_ncurses("Filename to find ? ");
+ if(needle!=NULL && needle[0]!='\0')
+ {
+ file_data_t *pos_org=pos;
+ const int pos_num_org=pos_num;
+ while(strcmp(pos->name, needle)!=0 && pos->next!=NULL)
+ {
+ pos=pos->next;
+ pos_num++;
+ }
+ if(strcmp(pos->name, needle)!=0)
+ {
+ pos=pos_org;
+ pos_num=pos_num_org;
+ }
+ }
+ }
+ break;
}
if(pos_num<offset)
offset=pos_num;
diff --git a/src/intrfn.c b/src/intrfn.c
index 365d9de..e5a2018 100644
--- a/src/intrfn.c
+++ b/src/intrfn.c
@@ -1426,6 +1426,61 @@ void display_message(const char*msg)
#endif
}
+uint64_t ask_int_ncurses(const char *string)
+{
+ WINDOW *local_win;
+ int startx, starty, width, height;
+ uint64_t min_size=0;
+ char response[128];
+ height = 3;
+ width = 40;
+ starty = (LINES - height) / 2; /* Calculating for a center placement */
+ startx = (COLS - width) / 2; /* of the window */
+
+ local_win = newwin(height, width, starty, startx);
+ keypad(local_win, TRUE); /* Need it to get arrow key */
+ box(local_win, 0 , 0); /* 0, 0 gives default characters
+ * for the vertical and horizontal
+ * lines */
+ wmove(local_win,1,1);
+ waddstr(local_win, string);
+ wrefresh(local_win); /* Show that box */
+ if (get_string(local_win, response, 16, NULL) > 0)
+ {
+ min_size = strtoull(response, NULL, 10);
+ }
+ wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
+ wrefresh(local_win);
+ delwin(local_win);
+ return min_size;
+}
+
+const char *ask_string_ncurses(const char *string)
+{
+ WINDOW *local_win;
+ int startx, starty, width, height;
+ static char response[128];
+ height = 3;
+ width = 60;
+ starty = (LINES - height) / 2; /* Calculating for a center placement */
+ startx = (COLS - width) / 2; /* of the window */
+
+ local_win = newwin(height, width, starty, startx);
+ keypad(local_win, TRUE); /* Need it to get arrow key */
+ box(local_win, 0 , 0); /* 0, 0 gives default characters
+ * for the vertical and horizontal
+ * lines */
+ wmove(local_win,1,1);
+ waddstr(local_win, string);
+ wrefresh(local_win); /* Show that box */
+ get_string(local_win, response, 40, NULL);
+ wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
+ wrefresh(local_win);
+ delwin(local_win);
+ return &response[0];
+}
+
+
#else
#include "log.h"
#include "intrfn.h"
diff --git a/src/intrfn.h b/src/intrfn.h
index 161d261..581586c 100644
--- a/src/intrfn.h
+++ b/src/intrfn.h
@@ -58,6 +58,8 @@ int interface_partition_type_ncurses(disk_t *disk_car);
int vaff_txt(int line, WINDOW *window, const char *_format, va_list ap) __attribute__((format(printf, 3, 0)));
char *ask_log_location(const char*filename);
int get_string(WINDOW *window, char *str, const int len, const char *def);
+uint64_t ask_int_ncurses(const char *string);
+const char *ask_string_ncurses(const char *string);
#endif
void display_message(const char*msg);
diff --git a/src/ntfs_udl.c b/src/ntfs_udl.c
index d39cd3d..f5f6b36 100644
--- a/src/ntfs_udl.c
+++ b/src/ntfs_udl.c
@@ -1244,60 +1244,6 @@ static struct td_list_head *ntfs_prev_non_deleted(struct td_list_head *current_f
return current_file;
}
-static uint64_t ask_int_ncurses(const char *string)
-{
- WINDOW *local_win;
- int startx, starty, width, height;
- uint64_t min_size=0;
- char response[128];
- height = 3;
- width = 40;
- starty = (LINES - height) / 2; /* Calculating for a center placement */
- startx = (COLS - width) / 2; /* of the window */
-
- local_win = newwin(height, width, starty, startx);
- keypad(local_win, TRUE); /* Need it to get arrow key */
- box(local_win, 0 , 0); /* 0, 0 gives default characters
- * for the vertical and horizontal
- * lines */
- wmove(local_win,1,1);
- waddstr(local_win, string);
- wrefresh(local_win); /* Show that box */
- if (get_string(local_win, response, 16, NULL) > 0)
- {
- min_size = strtoull(response, NULL, 10);
- }
- wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
- wrefresh(local_win);
- delwin(local_win);
- return min_size;
-}
-
-static const char *ask_string_ncurses(const char *string)
-{
- WINDOW *local_win;
- int startx, starty, width, height;
- static char response[128];
- height = 3;
- width = 60;
- starty = (LINES - height) / 2; /* Calculating for a center placement */
- startx = (COLS - width) / 2; /* of the window */
-
- local_win = newwin(height, width, starty, startx);
- keypad(local_win, TRUE); /* Need it to get arrow key */
- box(local_win, 0 , 0); /* 0, 0 gives default characters
- * for the vertical and horizontal
- * lines */
- wmove(local_win,1,1);
- waddstr(local_win, string);
- wrefresh(local_win); /* Show that box */
- get_string(local_win, response, 40, NULL);
- wborder(local_win, ' ', ' ', ' ',' ',' ',' ',' ',' ');
- wrefresh(local_win);
- delwin(local_win);
- return &response[0];
-}
-
static void ntfs_undelete_menu_ncurses(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, file_info_t *dir_list)
{
struct ntfs_dir_struct *ls=(struct ntfs_dir_struct *)dir_data->private_dir_data;