summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2009-11-20 00:59:37 (GMT)
committerChristian Pointner <equinox@helsinki.at>2009-11-20 00:59:37 (GMT)
commit7db46037c3d70c129e0702a22c91d9928d5dfb0a (patch)
tree5b627ce9eb6986ef234042d8ffc42edf112bb533
parent9400922264824b46a447487e56642ef2e8167236 (diff)
added find methods to watch_list
-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);