From 784991b7bb9622c6a3f22b5eec762023fb8d94cb Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Fri, 29 Sep 2017 06:14:21 +1000 Subject: [PATCH] Add file order prompt --- magicka.strings | 1 + src/files.c | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/magicka.strings b/magicka.strings index a68b4be..71280be 100644 --- a/magicka.strings +++ b/magicka.strings @@ -231,3 +231,4 @@ File exists!\r\n \r\n\e[1;37mAre you sure you want to reset \e[1;31mall messages \e[1;37min all bases to unread? \e[0m \r\n\r\n\e[1;30m[\e[1;34m%3d\e[1;30m] \e[1;33m%3ddloads \e[1;36m%4d%c \e[1;37m%-56s\r\n \e[1;31mNEW \e[0;32m \r\nScan for new files? (Y/N) : +\r\n\e[1;37mOrder by (\e1;32mF\e[1;37m)ilename, (\e[1;32mU\e[1;37m)pload Date, (\e1;32mP\e[1;37m)opularity : \e[0m diff --git a/src/files.c b/src/files.c index 7c0dcff..0ba1d98 100644 --- a/src/files.c +++ b/src/files.c @@ -854,7 +854,10 @@ void download(struct user_record *user) { } void list_files(struct user_record *user) { - char *sql = "select filename, description, size, dlcount, uploaddate from files where approved=1"; + char *dsql = "select filename, description, size, dlcount, uploaddate from files where approved=1 ORDER BY uploaddate DESC"; + char *fsql = "select filename, description, size, dlcount, uploaddate from files where approved=1 ORDER BY filename"; + char *psql = "select filename, description, size, dlcount, uploaddate from files where approved=1 ORDER BY dlcount DESC"; + char *sql; char buffer[PATH_MAX]; sqlite3 *db; sqlite3_stmt *res; @@ -869,8 +872,25 @@ void list_files(struct user_record *user) { int k; int match; + char ch; struct file_entry **files_e; + s_printf(get_string(233)); + ch = s_getc(); + + switch(tolower(ch)) { + case 'u': + sql = dsql; + break; + case 'p': + sql = psql; + break; + default: + sql = fsql; + break; + + } + s_printf("\r\n"); snprintf(buffer, PATH_MAX, "%s/%s.sq3", conf.bbs_path, conf.file_directories[user->cur_file_dir]->file_subs[user->cur_file_sub]->database); rc = sqlite3_open(buffer, &db);