1 /*------------- Telecommunications & Signal Processing Lab -------------
2                           McGill University
3 
4 Routine:
5   int FLpreName (const char Fname[], char Pname[])
6 
7 Purpose:
8   Return the last component of a file name stripped of its extension
9 
10 Description:
11   This routine takes a filename and returns the last component of the filename
12   stripped of the filename extension.  The extension is the part of the last
13   component of the path name beginning with (and including) a period.  The
14   string returned for a path name "/abc/def.gh.ij" is "def.gh".
15 
16 Parameters:
17   <-  int FLpreName
18       Number of characters in the output string
19    -> const char Fname[]
20       Input character string with the file name
21   <-  char Pname[]
22       Output string filename string without the extension.  This string is
23       at most FILENAME_MAX characters long including the terminating null
24       character.
25 
26 Author / revision:
27   P. Kabal  Copyright (C) 2003
28   $Revision: 1.8 $  $Date: 2003/05/09 01:36:44 $
29 
30 ----------------------------------------------------------------------*/
31 
32 #include <string.h>
33 
34 #include <libtsp.h>
35 
36 
37 int
FLpreName(const char Fname[],char Pname[])38 FLpreName (const char Fname[], char Pname[])
39 
40 {
41   char *p;
42   int n;
43   char Bname[FILENAME_MAX];
44 
45   FLbaseName (Fname, Bname);
46   p = strrchr (Bname, '.');
47   if (p != NULL)
48     *p = '\0';
49   n = STcopyMax (Bname, Pname, FILENAME_MAX-1);
50 
51   return n;
52 }
53