1 #include <lightmediascanner_utils.h>
6 * Strips string, in place.
8 * @param str string to be stripped.
9 * @param p_len string length to analyse, also the place where the final size
13 lms_strstrip(char *str, unsigned int *p_len)
20 if (len < 2) /* just '\0'? */
24 for (i = len - 1; i >= 0; i--) {
38 for (i = 0; i < len; i++) {
54 for (; len > 0; len--, str++, p++)
59 * Find out which of the given extensions matches the given name.
61 * @param name string to analyse.
62 * @param name_len string length.
63 * @param exts array of extensions to be checked.
64 * @param exts_len number of items in array @p exts
66 * @return index in @p exts or -1 if it doesn't match none.
69 lms_which_extension(const char *name, unsigned int name_len, const struct lms_string_size *exts, unsigned int exts_len) {
71 unsigned int *exts_pos;
74 exts_pos = alloca(exts_len * sizeof(*exts_pos));
75 for (i = 0; i < exts_len; i++)
76 exts_pos[i] = exts[i].len;
78 for (s = name + name_len - 1; s >= name; s--) {
89 for (i = 0; i < exts_len; i++) {
90 if (exts_pos[i] > 0) {
93 ce = exts[i].str[exts_pos[i] - 1];
94 if (ce == c1 || ce == c2) {