/*------------- Telecommunications & Signal Processing Lab ------------- McGill University Routine: int FLextName (const char Fname[], char Ext[]) Purpose: Return the extension component of a file name Description: This routine takes a filename and returns the filename extension. The extension is the part of the last component of the path name beginning with (and including) a period. The extension for the path name "/abc/def.ghi" is ".ghi". Parameters: <- int FLextName Number of characters in the output string -> const char Fname[] Input character string with the file name <- char Ext[] Output string with the extension. This string is at most FILENAME_MAX characters long not including the terminating null character. Author / revision: P. Kabal Copyright (C) 1995 $Revision: 1.2 $ $Date: 1995/05/12 11:25:06 $ ----------------------------------------------------------------------*/ static char rcsid[] = "$Id: FLextName.c 1.2 1995/05/12 AFsp-V2R1 $"; #include #include int FLextName (Fname, Ext) const char Fname[]; char Ext[]; { char Bname[FILENAME_MAX]; char *p; int n; FLbaseName (Fname, Bname); p = strchr (Bname, '.'); if (p != NULL) n = STcopyMax (p, Ext, FILENAME_MAX); else { Ext[0] = '\0'; n = 0; } return n; }