aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2010-12-10 17:46:23 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2010-12-10 17:46:23 -0500
commit061486aed157f8d992f43ba9d45eb4e160a3a3ee (patch)
treebbbd05e8aeb044265ef1827eb8e48d02bdc51c63
parentf8ff3e5854b6bd4b61061b6d521619e076623183 (diff)
downloadNetNuke2-061486aed157f8d992f43ba9d45eb4e160a3a3ee.tar.gz
UI changes... Sort of getting there.
-rw-r--r--include/netnuke.h1
-rw-r--r--src/nukectl.c17
-rw-r--r--src/output_redirect.c8
3 files changed, 22 insertions, 4 deletions
diff --git a/include/netnuke.h b/include/netnuke.h
index dc78ef2..1a11bcf 100644
--- a/include/netnuke.h
+++ b/include/netnuke.h
@@ -70,6 +70,7 @@ void free_window(WINDOW* window);
void* main_window_worker(void* args);
void main_init(void);
void main_deinit(void);
+void update_window(WINDOW* window);
#endif //NETNUKE_H
diff --git a/src/nukectl.c b/src/nukectl.c
index de6b28d..cf39f6c 100644
--- a/src/nukectl.c
+++ b/src/nukectl.c
@@ -30,6 +30,7 @@
FILE* randfp;
int writing = 0;
+int rowpos = 0;
unsigned int randseed;
unsigned long long total_written_bytes = 0;
extern unsigned int blksz_override;
@@ -66,6 +67,14 @@ void* wipe(void* device)
unsigned long long block = 0;
unsigned long long bytes_out = 0;
long double percent = 0.0L;
+ int lrow = 0;
+
+ pthread_mutex_lock(&lock_global);
+ rowpos++;
+ lrow = rowpos;
+ pthread_mutex_unlock(&lock_global);
+
+
if(d->path[0] == 0)
{
@@ -82,7 +91,7 @@ void* wipe(void* device)
COM(self, "Unable to open %s: %s\n", d->path, strerror(errno));
return (int*)1;
}
- COM(self, "%s, block size %d, blocks %llu, total bytes %llu\n", d->path, d->blksz, d->blks, d->sz);
+ COM(self, "%s, block size %d, blocks %llu, total bytes %llu", d->path, d->blksz, d->blks, d->sz);
srand(nngetseed());
times = d->sz / d->blksz;
@@ -94,8 +103,10 @@ void* wipe(void* device)
{
percent = (long double)((bytes_out / (long double)d->sz) * 100);
//COM(self, "%s: %llu of %llu (%0.2Lf%%)\n", d->path, bytes_out, d->sz, percent);
- mvwprintw(info_window, 0, 0, "%s: %llu of %llu (%0.2Lf%%)\n", d->path, bytes_out, d->sz, percent);
- wrefresh(info_window);
+ pthread_mutex_lock(&lock_global);
+ mvwprintw(info_window, lrow, 2, "%s: %llu of %llu (%0.2Lf%%)\r", d->path, bytes_out, d->sz, percent);
+ update_window(info_window);
+ pthread_mutex_unlock(&lock_global);
}
bytes_out += nnwrite(fd, d->blksz);
block++;
diff --git a/src/output_redirect.c b/src/output_redirect.c
index f29bbea..1aa70ed 100644
--- a/src/output_redirect.c
+++ b/src/output_redirect.c
@@ -43,6 +43,7 @@ int nnlogcleanup()
extern WINDOW* main_window;
extern pthread_mutex_t main_window_lock;
+int printrow = 0;
int COM(const char* func, char *format, ...)
{
struct tm *logtm;
@@ -79,8 +80,13 @@ int COM(const char* func, char *format, ...)
{
snprintf(tmpstr, sizeof(tmpstr), "_%s_: %s", func, str);
//fprintf(stdout, "%s", tmpstr);
+ pthread_mutex_lock(&main_window_lock);
+ //mvprintw(main_window, printrow, 2, "%s", tmpstr);
wprintw(main_window, "%s", tmpstr);
- wrefresh(main_window);
+ wmove(main_window, printrow, 2);
+ update_window(main_window);
+ printrow++;
+ pthread_mutex_unlock(&main_window_lock);
}
free(str);