00001 #include <ctype.h>
00002 #include <string.h>
00003
00022 char * G_basename(char *filename, const char *desired_ext)
00023 {
00024
00025 char *dot = strrchr(filename, '.');
00026
00027
00028
00029 if(dot && ((dot - filename) < strlen(filename)) )
00030 {
00031 char *ext = dot + 1;
00032 int i, match = 1;
00033
00034
00035
00036 for( i = 0; i < strlen(desired_ext); i++ )
00037 {
00038 if( (ext[i] == '\0') || (tolower(ext[i]) != tolower(desired_ext[i])) )
00039 {
00040 match = 0;
00041 break;
00042 }
00043 }
00044
00045 if( match )
00046 *dot = '\0';
00047
00048 }
00049
00050 return filename;
00051 }