summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--entry.c17
-rw-r--r--entry.obin3520 -> 4064 bytes
-rw-r--r--read_cfg.c31
-rw-r--r--read_cfg.obin5760 -> 6320 bytes
4 files changed, 35 insertions, 13 deletions
diff --git a/entry.c b/entry.c
index 4b6d03d..f9647f5 100644
--- a/entry.c
+++ b/entry.c
@@ -22,17 +22,28 @@ char *get_epath(ENTRY *e);
ENTRY *create_entry(char *new_name, char *new_path){
ENTRY *new;
+ char adjusted_path[BUF_LEN];
//double check if file exists
if(access(new_path, F_OK) == -1){
- printf("Error: Invalid File Name \"%s\"\n", new_path);
- return NULL;
+ //try to adjust the path, in case of lingering quotes
+ strcpy(adjusted_path, &new_path[1]);
+ adjusted_path[strlen(adjusted_path)-1] = '\0';
+
+ if(access(adjusted_path, F_OK) == -1){
+ printf("Error: Invalid File Name \"%s\"\n", new_path);
+ return NULL;
+ }
}
+ else strcpy(adjusted_path, new_path);
+
new = malloc(sizeof(ENTRY));
strcpy(new->name, new_name);
- strcpy(new->path, new_path);
+ strcpy(new->path, adjusted_path);
+ printf("1 DEBUG: %s\n", adjusted_path);
+ printf("2 DEBUG: %s\n", adjusted_path);
new->next = NULL;
return new;
diff --git a/entry.o b/entry.o
index 0c2cc9d..4b56b98 100644
--- a/entry.o
+++ b/entry.o
Binary files differ
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;
}
diff --git a/read_cfg.o b/read_cfg.o
index 5bbca6b..fd942a8 100644
--- a/read_cfg.o
+++ b/read_cfg.o
Binary files differ