source: src/utils/strutils.c @ 88b301a

feature/autosinkfeature/cnnfeature/crepefix/ffmpeg5
Last change on this file since 88b301a was 76b6dd3, checked in by Paul Brossier <piem@piem.org>, 5 years ago

[utils] use strnicmp on windows

  • Property mode set to 100644
File size: 1.4 KB
Line 
1/*
2  Copyright (C) 2018 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#include "aubio_priv.h"
22
23#ifdef HAVE_WIN_HACKS
24#define strncasecmp strnicmp
25#endif
26
27const char_t *aubio_str_get_extension(const char_t *filename)
28{
29  // find last occurence of dot character
30  const char_t *ext;
31  if (!filename) return NULL;
32  ext = strrchr(filename, '.');
33  if (!ext || ext == filename) return "";
34  else return ext + 1;
35}
36
37uint_t aubio_str_extension_matches(const char_t *ext, const char_t *pattern)
38{
39  return ext && pattern && (strncasecmp(ext, pattern, PATH_MAX) == 0);
40}
41
42uint_t aubio_str_path_has_extension(const char_t *filename,
43    const char_t *pattern)
44{
45  const char_t *ext = aubio_str_get_extension(filename);
46  return aubio_str_extension_matches(ext, pattern);
47}
Note: See TracBrowser for help on using the repository browser.