Drizzled Public API Documentation

mf_fn_ext.cc
00001 /* Copyright (C) 2000 MySQL AB
00002 
00003    This program is free software; you can redistribute it and/or modify
00004    it under the terms of the GNU General Public License as published by
00005    the Free Software Foundation; version 2 of the License.
00006 
00007    This program is distributed in the hope that it will be useful,
00008    but WITHOUT ANY WARRANTY; without even the implied warranty of
00009    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010    GNU General Public License for more details.
00011 
00012    You should have received a copy of the GNU General Public License
00013    along with this program; if not, write to the Free Software
00014    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
00015 
00016 #include <config.h>
00017 
00018 #include <drizzled/internal/my_sys.h>
00019 #include <drizzled/internal/m_string.h>
00020 
00021 namespace drizzled
00022 {
00023 namespace internal
00024 {
00025 
00026 /*
00027   Return a pointer to the extension of the filename.
00028 
00029   SYNOPSIS
00030     fn_ext()
00031     name    Name of file
00032 
00033   DESCRIPTION
00034     The extension is defined as everything after the first extension character
00035     (normally '.') after the directory name.
00036 
00037   RETURN VALUES
00038     Pointer to to the extension character. If there isn't any extension,
00039     points at the end ASCII(0) of the filename.
00040 */
00041 
00042 char *fn_ext(const char *name)
00043 {
00044   const char *pos, *gpos;
00045 
00046 #if defined(FN_DEVCHAR)
00047   {
00048     char buff[FN_REFLEN];
00049     size_t res_length;
00050     gpos= name+ dirname_part(buff,(char*) name, &res_length);
00051   }
00052 #else
00053   if (!(gpos= strrchr(name, FN_LIBCHAR)))
00054     gpos= name;
00055 #endif
00056   pos=strchr(gpos,FN_EXTCHAR);
00057   return((char*) (pos ? pos : strchr(gpos, '\0')));
00058 } /* fn_ext */
00059 
00060 } /* namespace internal */
00061 } /* namespace drizzled */