diff options
Diffstat (limited to 'src/bookmarks.c')
-rw-r--r-- | src/bookmarks.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/bookmarks.c b/src/bookmarks.c index 7e98fb27..f97ef0c6 100644 --- a/src/bookmarks.c +++ b/src/bookmarks.c | |||
@@ -54,7 +54,7 @@ static const char *fileName_Bookmarks_ = "bookmarks.txt"; | |||
54 | struct Impl_Bookmarks { | 54 | struct Impl_Bookmarks { |
55 | iMutex *mtx; | 55 | iMutex *mtx; |
56 | int idEnum; | 56 | int idEnum; |
57 | iHash bookmarks; | 57 | iHash bookmarks; /* bookmark ID is the hash key */ |
58 | }; | 58 | }; |
59 | 59 | ||
60 | iDefineTypeConstruction(Bookmarks) | 60 | iDefineTypeConstruction(Bookmarks) |
@@ -173,6 +173,17 @@ iBool filterTagsRegExp_Bookmarks(void *regExp, const iBookmark *bm) { | |||
173 | return matchString_RegExp(regExp, &bm->tags, &m); | 173 | return matchString_RegExp(regExp, &bm->tags, &m); |
174 | } | 174 | } |
175 | 175 | ||
176 | static iBool matchUrl_(void *url, const iBookmark *bm) { | ||
177 | return equalCase_String(url, &bm->url); | ||
178 | } | ||
179 | |||
180 | uint32_t findUrl_Bookmarks(const iBookmarks *d, const iString *url) { | ||
181 | /* TODO: O(n), boo */ | ||
182 | const iPtrArray *found = list_Bookmarks(d, NULL, matchUrl_, (void *) url); | ||
183 | if (isEmpty_PtrArray(found)) return 0; | ||
184 | return id_Bookmark(constFront_PtrArray(found)); | ||
185 | } | ||
186 | |||
176 | const iPtrArray *list_Bookmarks(const iBookmarks *d, iBookmarksCompareFunc cmp, | 187 | const iPtrArray *list_Bookmarks(const iBookmarks *d, iBookmarksCompareFunc cmp, |
177 | iBookmarksFilterFunc filter, void *context) { | 188 | iBookmarksFilterFunc filter, void *context) { |
178 | lock_Mutex(d->mtx); | 189 | lock_Mutex(d->mtx); |