summaryrefslogtreecommitdiff
path: root/read_cfg.c
diff options
context:
space:
mode:
authorlouie <lshprung@yahoo.com>2020-06-26 19:43:29 -0700
committerlouie <lshprung@yahoo.com>2020-06-26 19:43:29 -0700
commit0eb46442f5541f365ebb327375b9e5992194fbd8 (patch)
treef3dc085d59fbace14ef4f4b5f60e5c4e22596591 /read_cfg.c
parent7985c945cf11c50559daa8bdb03f9a023deb2da3 (diff)
Added compatability for spaces in filename
Diffstat (limited to 'read_cfg.c')
-rw-r--r--read_cfg.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/read_cfg.c b/read_cfg.c
index 745c55a..51572c1 100644
--- a/read_cfg.c
+++ b/read_cfg.c
@@ -61,14 +61,14 @@ void cfg_interp(){
void check_line(char *buffer){
char *delims = " \t\n";
char *tok = strtok(buffer, delims);
- char *args[MAX_ARGS];
+ char args[MAX_ARGS][BUF_LEN];
GROUP **g;
int g_count;
int i;
- //initialize args to NULL
+ //initialize args to 0
for(i = 0; i < MAX_ARGS; i++){
- args[i] = NULL;
+ args[i][0] = '\0';
}
i = 0;
@@ -78,7 +78,16 @@ void check_line(char *buffer){
printf("Error: too many arguments\n");
return;
}
- args[i] = tok;
+ strcpy(args[i], tok);
+ //handle if an argument has spaces and is wrapped in quotes
+ if(tok[0] == '"'){
+ while(tok[strlen(tok)-1] != '"'){
+ tok = strtok(NULL, delims);
+ strcat(args[i], " ");
+ strcat(args[i], tok);
+ }
+ }
+
tok = strtok(NULL, delims);
i++;
}
@@ -164,16 +173,18 @@ void handle_fname(char *path, char *group){
//directory is not real, report error to the user
else printf("Error: \"%s\" bad path\n", dirname);
}
- }
- //file name is okay
- else{
- new = create_entry(path, path);
- if(new != NULL){
- group_add(group, new);
+ //file name is okay
+ else{
+ new = create_entry(path, path);
+ if(new != NULL){
+ group_add(group, new);
+ }
}
}
+ else printf("Error: \"%s\" bad path\n", path);
+
return;
}