1
2
3
4
5
6
7#include <fnmatch.h>
8#include "libbb.h"
9#include "bb_archive.h"
10
11
12const llist_t* FAST_FUNC find_list_entry(const llist_t *list, const char *filename)
13{
14 while (list) {
15 if (fnmatch(list->data, filename, 0) == 0) {
16 return list;
17 }
18 list = list->link;
19 }
20 return NULL;
21}
22
23
24
25
26const llist_t* FAST_FUNC find_list_entry2(const llist_t *list, const char *filename)
27{
28 char buf[PATH_MAX];
29 int pattern_slash_cnt;
30 const char *c;
31 char *d;
32
33 while (list) {
34 c = list->data;
35 pattern_slash_cnt = 0;
36 while (*c)
37 if (*c++ == '/') pattern_slash_cnt++;
38 c = filename;
39 d = buf;
40
41 while (*c && d != buf + sizeof(buf)-1) {
42 if (*c == '/' && --pattern_slash_cnt < 0)
43 break;
44 *d++ = *c++;
45 }
46 *d = '\0';
47 if (fnmatch(list->data, buf, 0) == 0) {
48 return list;
49 }
50 list = list->link;
51 }
52 return NULL;
53}
54