diff options
author | Christian Pointner <equinox@helsinki.at> | 2009-11-20 02:11:28 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2009-11-20 02:11:28 (GMT) |
commit | 440f0502990098326b2d8e4935da35809a0532a8 (patch) | |
tree | 049523d9d2bb299dd5dfd9c4f29f3fe77b64874b /watch_list.c | |
parent | 45a56fdac919977e22d8ad4bc73d5d223520b338 (diff) |
add and remove should work now
Diffstat (limited to 'watch_list.c')
-rw-r--r-- | watch_list.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/watch_list.c b/watch_list.c index 4339b85..28ca97d 100644 --- a/watch_list.c +++ b/watch_list.c @@ -88,6 +88,38 @@ int watch_list_add(watch_list_t* list, int watch_fd, const char* string) return 0; } +void watch_list_rm(watch_list_t* list, const char* path) +{ + if(!list) + return; + + watch_list_element_t* tmp = NULL; + if(list->first_->path_ && !strcmp(path, list->first_->path_)) { + tmp = list->first_; + list->first_ = list->first_->next_; + + if(tmp->path_) + free(tmp->path_); + free(tmp); + return; + } + + watch_list_element_t* prev = list->first_; + tmp = list->first_->next_; + while(tmp) { + if(tmp->path_ && !strcmp(path, tmp->path_)) { + prev->next_ = tmp->next_; + + if(tmp->path_) + free(tmp->path_); + free(tmp); + return; + } + prev = tmp; + tmp = tmp->next_; + } +} + char* watch_list_find_path(watch_list_t* list, int watch_fd) { if(!list) |