summaryrefslogtreecommitdiff
path: root/read_cfg.c
diff options
context:
space:
mode:
authorlouie <lshprung@yahoo.com>2020-08-02 18:09:03 -0700
committerlouie <lshprung@yahoo.com>2020-08-02 18:09:03 -0700
commit7cab81c193a01775d804fb037f7d26c6a6806e74 (patch)
treeba6049ca4c3243496bcd46c1f5639d8f69591e7a /read_cfg.c
parent2ee23565a15bd969828db7442f2f8b4902d5e261 (diff)
Added option to sort entries
Diffstat (limited to 'read_cfg.c')
-rw-r--r--read_cfg.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/read_cfg.c b/read_cfg.c
index bfe118a..9bf64ee 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -10,12 +10,13 @@
#include "group.h"
#define BUF_LEN 1024 //maybe move this line to the header file
#define MAX_ARGS 5
-#define OPTION_CNT 10
+#define OPTION_CNT 11
//public
char *find_config();
void cfg_interp(char *path);
int get_compmode();
+bool get_sort();
//private
void check_line(char *buffer, char **options);
@@ -33,6 +34,9 @@ int compmode = 0;
//1 -> WSL
//maybe more later?
+//turn on or off sorting (A-Z)
+bool sort = 0;
+
//set to true to automatically try to create a human readable name for an entry
bool hr = false;
@@ -76,7 +80,6 @@ void cfg_interp(char *path){
int i;
int j;
- //TODO have this check in certain locations for a config file, give error message if "config" does not exist
fp = fopen(path, "r");
assert(fp != NULL);
@@ -92,6 +95,7 @@ void cfg_interp(char *path){
options[7] = "compMode";
options[8] = "setFlags";
options[9] = "setLauncher";
+ options[10] = "sort";
//Read each line of "config"
while(fgets(buffer, BUF_LEN, fp)){
@@ -124,7 +128,11 @@ int get_compmode(){
return compmode;
}
-//TODO add support for "addR" recursive adding
+bool get_sort(){
+ return sort;
+}
+
+//TODO add support for "addR" recursive adding (still needs work...)
//TODO add support for "alias" option
//TODO add support for "hide" option
void check_line(char *buffer, char **options){
@@ -195,7 +203,6 @@ void check_line(char *buffer, char **options){
case 0: //add
//add entry(ies) to a group: first arg is the file(s), second arg is the group to add to
- //TODO add potential dash functions
//TODO add sorting functionality
handle_fname(args[1], args[2], 0, 0, NULL);
break;
@@ -268,6 +275,11 @@ void check_line(char *buffer, char **options){
else printf("Error: Group \"%s\" does not exist\n", args[1]);
break;
+ case 10: //sort
+ if(!(strcmp(args[1], "on"))) sort = true;
+ else if(!(strcmp(args[1], "off"))) sort = false;
+ break;
+
default:
printf("Error: Unknown config option \"%s\"\n", args[0]);