6 |
*/ |
*/ |
7 |
|
|
8 |
#include <fnmatch.h> |
#include <fnmatch.h> |
9 |
#include <stdlib.h> |
#include "libbb.h" |
10 |
#include "unarchive.h" |
#include "unarchive.h" |
11 |
|
|
12 |
/* Find a string in a shell pattern list */ |
/* Find a string in a shell pattern list */ |
13 |
const llist_t *find_list_entry(const llist_t *list, const char *filename) |
const llist_t* FAST_FUNC find_list_entry(const llist_t *list, const char *filename) |
14 |
{ |
{ |
15 |
while (list) { |
while (list) { |
16 |
if (fnmatch(list->data, filename, 0) == 0) { |
if (fnmatch(list->data, filename, 0) == 0) { |
24 |
/* Same, but compares only path components present in pattern |
/* Same, but compares only path components present in pattern |
25 |
* (extra trailing path components in filename are assumed to match) |
* (extra trailing path components in filename are assumed to match) |
26 |
*/ |
*/ |
27 |
const llist_t *find_list_entry2(const llist_t *list, const char *filename) |
const llist_t* FAST_FUNC find_list_entry2(const llist_t *list, const char *filename) |
28 |
{ |
{ |
29 |
char buf[PATH_MAX]; |
char buf[PATH_MAX]; |
30 |
int pattern_slash_cnt; |
int pattern_slash_cnt; |
38 |
if (*c++ == '/') pattern_slash_cnt++; |
if (*c++ == '/') pattern_slash_cnt++; |
39 |
c = filename; |
c = filename; |
40 |
d = buf; |
d = buf; |
41 |
/* paranoia is better that buffer overflows */ |
/* paranoia is better than buffer overflows */ |
42 |
while (*c && d != buf + sizeof(buf)-1) { |
while (*c && d != buf + sizeof(buf)-1) { |
43 |
if (*c == '/' && --pattern_slash_cnt < 0) |
if (*c == '/' && --pattern_slash_cnt < 0) |
44 |
break; |
break; |