summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--watch_list.c30
-rw-r--r--watch_list.h2
2 files changed, 32 insertions, 0 deletions
diff --git a/watch_list.c b/watch_list.c
index 1f5089d..81b850f 100644
--- a/watch_list.c
+++ b/watch_list.c
@@ -88,6 +88,36 @@ int watch_list_add(watch_list_t* list, int watch_fd, const char* string)
return 0;
}
+char* watch_list_find_path(watch_list_t* list, int watch_fd)
+{
+ if(!list)
+ return NULL;
+
+ watch_list_element_t* tmp = list->first_;
+ while(tmp) {
+ if(tmp->watch_fd_ == watch_fd)
+ return tmp->path_;
+ tmp = tmp->next_;
+ }
+
+ return NULL;
+}
+
+int watch_list_find_fd(watch_list_t* list, const char* path)
+{
+ if(!list || !path)
+ return -1;
+
+ watch_list_element_t* tmp = list->first_;
+ while(tmp) {
+ if(tmp->path && !strcmp(path, tmp->path))
+ return tmp->path_;
+ tmp = tmp->next_;
+ }
+
+ return -1;
+}
+
void watch_list_print(watch_list_t* list, const char* head, const char* sep, const char* tail)
{
if(!list)
diff --git a/watch_list.h b/watch_list.h
index 8c3fa63..931b656 100644
--- a/watch_list.h
+++ b/watch_list.h
@@ -37,6 +37,8 @@ typedef struct watch_list_struct watch_list_t;
void watch_list_init(watch_list_t* list);
void watch_list_clear(watch_list_t* list);
int watch_list_add(watch_list_t* list, int watch_fd, const char* path);
+char* watch_list_find_path(watch_list_t* list, int watch_fd);
+int watch_list_find_fd(watch_list_t* list, const char* path);
void watch_list_print(watch_list_t* list, const char* head, const char* sep, const char* tail);