parsing filename for filetype
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
@@ -42,3 +42,24 @@ if (1 == foo) {
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int format_from_extension(char *fname)
|
||||
{
|
||||
char *cptr;
|
||||
|
||||
cptr = rindex(fname, '.');
|
||||
if (NULL==cptr) {
|
||||
fprintf(stderr, "do dot in %s\n", fname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "[%s] --> [%s]\n", fname, cptr);
|
||||
#endif
|
||||
|
||||
if (!strcasecmp(cptr, ".pnm")) return FILE_TYPE_PNM;
|
||||
if (!strcasecmp(cptr, ".fimg")) return FILE_TYPE_FIMG;
|
||||
if (!strcasecmp(cptr, ".png")) return FILE_TYPE_PNG;
|
||||
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
Reference in New Issue
Block a user