diff options
author | louie <lshprung@yahoo.com> | 2020-06-22 21:08:10 -0700 |
---|---|---|
committer | louie <lshprung@yahoo.com> | 2020-06-22 21:08:10 -0700 |
commit | 43eeda3d0982160d7863dd2268d989f79c24f03f (patch) | |
tree | 8beca0a69f63b520683148f3a265b8b5806c7f6b /read_cfg.c | |
parent | 4ca501cb1ded2bf4466a28fcad28a6b7c60d8aff (diff) |
Altered Group Structure and cfg
Diffstat (limited to 'read_cfg.c')
-rw-r--r-- | read_cfg.c | 36 |
1 files changed, 11 insertions, 25 deletions
@@ -53,40 +53,26 @@ void cfg_interp(){ void check_line(char *buffer){ char *delims = " \t\n"; char *tok = strtok(buffer, delims); - DIR *dp; - struct dirent *d_entry; ENTRY *new; - //add a path to the entry list + //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 account for spaces in file name + //TODO add regex support for adding patterns + //TODO allow adding directories (might fall into regex support) if(!(strcmp(tok, "add"))){ - tok = strtok(NULL, delims); - new = create_entry(tok, NULL); + //look at first arg + tok = strtok(NULL, delims); + new = create_entry(tok, tok); + //look at second arg + tok = strtok(NULL, delims); if(new != NULL) group_add(tok, new); } - //recursively add entries from a directory - if(!(strcmp(tok, "addDir"))){ + //create a new group + if(!(strcmp(tok, "addGroup"))){ tok = strtok(NULL, delims); - dp = opendir(tok); - - //check if the directory is valid - if(dp == NULL) printf("Error: Invalid Directory \"%s\"\n", tok); - - else{ - while((d_entry = readdir(dp))){ - //only add if its a file (d_type = 8) - if(d_entry->d_type == 8){ - new = create_entry(d_entry->d_name, tok); - if(new != NULL) group_add(tok, new); - } - } - } - - //TODO add option to also add files from directories inside directory (-r) - - closedir(dp); + group_add(tok, NULL); } return; |