This commit is contained in:
elvis
2022-03-31 22:26:44 +02:00
parent e86f981972
commit a5371ad4c7
6 changed files with 258 additions and 26 deletions

View File

@ -673,6 +673,38 @@ _end_find_in_queue:
return NULL;
}
// cerco
int searchFile(queueT *q, char *filepath) {
if(!q || !filepath) {
errno = EINVAL;
return NULL;
}
LOCK_RETURN(&q->m, NULL); // begin me
if (q->len == 0)
goto _end_search_file_in_queue;
nodeT *tmp = q->head;
while (tmp) {
if (strcmp(filepath, (tmp->data)->filepath) == 0) { // trovato
break;
}
tmp = tmp->next;
}
if(!tmp)
goto _end_search_file_in_queue;
UNLOCK_RETURN(&q->m, NULL); // end me
return 1;
_end_search_file_in_queue:
UNLOCK_RETURN(&q->m, NULL);
return 0;
}
// numero di elementi della queue
size_t getLen(queueT *q) {
if(!q) {