Drizzled Public API Documentation

mf_fn_ext.cc
1 /* Copyright (C) 2000 MySQL AB
2 
3  This program is free software; you can redistribute it and/or modify
4  it under the terms of the GNU General Public License as published by
5  the Free Software Foundation; version 2 of the License.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  GNU General Public License for more details.
11 
12  You should have received a copy of the GNU General Public License
13  along with this program; if not, write to the Free Software
14  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
15 
16 #include <config.h>
17 
18 #include <drizzled/internal/my_sys.h>
19 #include <drizzled/internal/m_string.h>
20 
21 namespace drizzled
22 {
23 namespace internal
24 {
25 
26 /*
27  Return a pointer to the extension of the filename.
28 
29  SYNOPSIS
30  fn_ext()
31  name Name of file
32 
33  DESCRIPTION
34  The extension is defined as everything after the first extension character
35  (normally '.') after the directory name.
36 
37  RETURN VALUES
38  Pointer to to the extension character. If there isn't any extension,
39  points at the end ASCII(0) of the filename.
40 */
41 
42 char *fn_ext(const char *name)
43 {
44  const char *pos, *gpos;
45 
46 #if defined(FN_DEVCHAR)
47  {
48  char buff[FN_REFLEN];
49  size_t res_length;
50  gpos= name+ dirname_part(buff,(char*) name, &res_length);
51  }
52 #else
53  if (!(gpos= strrchr(name, FN_LIBCHAR)))
54  gpos= name;
55 #endif
56  pos=strchr(gpos,FN_EXTCHAR);
57  return((char*) (pos ? pos : strchr(gpos, '\0')));
58 } /* fn_ext */
59 
60 } /* namespace internal */
61 } /* namespace drizzled */