38 #include <libidav/crypto.h> |
38 #include <libidav/crypto.h> |
39 #include <libidav/utils.h> |
39 #include <libidav/utils.h> |
40 |
40 |
41 #include "libxattr.h" |
41 #include "libxattr.h" |
42 |
42 |
43 uint32_t parse_finfo(const char *str) { |
43 uint32_t parse_finfo(const char *str, char **error) { |
44 scstr_t s = scstr(str); |
44 scstr_t s = scstr(str); |
45 |
45 |
46 if(!sstrcmp(s, SC("*")) || !sstrcmp(s, SC("a")) || !sstrcmp(s, SC("all"))) { |
46 if(!sstrcmp(s, SC("*")) || !sstrcmp(s, SC("a")) || !sstrcmp(s, SC("all"))) { |
47 return FINFO_DATE|FINFO_OWNER|FINFO_MODE; |
47 return FINFO_DATE|FINFO_OWNER|FINFO_MODE; |
48 } |
48 } |
49 |
49 |
50 size_t count = 0; |
50 size_t count = 0; |
51 sstr_t *fs = sstrsplit(s, SC(","), &count); |
51 sstr_t *fs = sstrsplit(s, SC(","), &count); |
|
52 |
|
53 char *err = NULL; |
52 |
54 |
53 uint32_t finfo = 0; |
55 uint32_t finfo = 0; |
54 for(int i=0;i<count;i++) { |
56 for(int i=0;i<count;i++) { |
55 sstr_t f = fs[i]; |
57 sstr_t f = fs[i]; |
56 if(!sstrcasecmp(f, SC("date"))) { |
58 if(!sstrcasecmp(f, SC("date"))) { |
59 finfo |= FINFO_OWNER; |
61 finfo |= FINFO_OWNER; |
60 } else if(!sstrcasecmp(f, SC("mode"))) { |
62 } else if(!sstrcasecmp(f, SC("mode"))) { |
61 finfo |= FINFO_MODE; |
63 finfo |= FINFO_MODE; |
62 } else if(!sstrcasecmp(f, SC("xattr"))) { |
64 } else if(!sstrcasecmp(f, SC("xattr"))) { |
63 finfo |= FINFO_XATTR; |
65 finfo |= FINFO_XATTR; |
|
66 } else if(error && !err) { |
|
67 err = fs[i].ptr; |
|
68 continue; |
64 } |
69 } |
65 free(f.ptr); |
70 free(f.ptr); |
66 } |
71 } |
67 |
72 |
68 free(fs); |
73 free(fs); |
69 return finfo; |
74 return err ? 0 : finfo; |
70 } |
75 } |
71 |
76 |
72 int resource_set_finfo(const char *path, DavResource *res, uint32_t finfo) { |
77 int resource_set_finfo(const char *path, DavResource *res, uint32_t finfo) { |
73 if(!path || finfo == 0) { |
78 if(!path || finfo == 0) { |
74 return 0; |
79 return 0; |