cake
/
libg1m
Archived
1
0
Fork 0

Lowercase'd.

This commit is contained in:
Thomas Touhey 2016-12-25 14:43:17 +01:00
parent a19e6ae3eb
commit 69e9bda504
1 changed files with 7 additions and 4 deletions

View File

@ -139,10 +139,11 @@ static struct ext_corresp ext_types[] = {
* Get extension from a path.
*
* @arg path the path.
* @arg extbuf the extension buffer.
* @return extension.
*/
static const char *get_extension(const char *path)
static void get_extension(const char *path, char *extbuf)
{
/* get filename */
const char *filename = strrchr(path, '/');
@ -152,8 +153,10 @@ static const char *get_extension(const char *path)
const char *ext = strrchr(filename, '.');
ext = ext ? ext + 1 : filename;
/* return it */
return (ext);
/* copy it */
extbuf[4] = 0; strncpy(extbuf, ext, 4);
for (int i = 0; i < 3; i++)
extbuf[i] = tolower(extbuf[i]);
}
/* ************************************************************************** */
@ -184,7 +187,7 @@ int g1m_get_type_info(const char *path,
&& !memcmp(subtype, "\xFF\xFF\xFF\xFF\xFF\xFF", 6)) {
log_info("Blank type! Let's use the extension to try and identify it.");
if (!path) return (1);
const char *ext = get_extension(path);
char ext[5]; get_extension(path, ext);
struct ext_corresp *e = ext_types - 1;
while ((++e)->ext) {