~drizzle-trunk/drizzle/development

1 by brian
clean slate
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
1802.10.2 by Monty Taylor
Update all of the copyright headers to include the correct address.
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
1 by brian
clean slate
15
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
16
#include "config.h"
17
18
#include "drizzled/internal/my_sys.h"
1241.9.64 by Monty Taylor
Moved remaining non-public portions of mysys and mystrings to drizzled/internal.
19
#include "drizzled/internal/m_string.h"
1 by brian
clean slate
20
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
21
namespace drizzled
22
{
23
namespace internal
24
{
25
1 by brian
clean slate
26
	/* Returns full load-path for a file. to may be = path */
27
	/* if path is a hard-path return path */
28
	/* if path starts with home-dir return path */
29
	/* if path starts with current dir or parent-dir unpack path */
30
	/* if there is no path, prepend with own_path_prefix if given */
31
	/* else unpack path according to current dir */
32
33
char * my_load_path(char * to, const char *path,
34
		       const char *own_path_prefix)
35
{
36
  char buff[FN_REFLEN];
37
  int is_cur;
38
39
  if ((path[0] == FN_HOMELIB && path[1] == FN_LIBCHAR) ||
40
      test_if_hard_path(path))
641.4.1 by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls
41
    strcpy(buff,path);
1 by brian
clean slate
42
  else if ((is_cur=(path[0] == FN_CURLIB && path[1] == FN_LIBCHAR)) ||
1241.9.12 by Monty Taylor
Trims more out of server_includes.h.
43
	   (strncmp(path,FN_PARENTDIR, strlen(FN_PARENTDIR)) == 0) ||
1 by brian
clean slate
44
	   ! own_path_prefix)
45
  {
46
    if (is_cur)
47
      is_cur=2;					/* Remove current dir */
895 by Brian Aker
Completion (?) of uint conversion.
48
    if (! getcwd(buff,(uint32_t) (FN_REFLEN-strlen(path)+is_cur)))
398.1.10 by Monty Taylor
Actually removed VOID() this time.
49
      strcat(buff,path+is_cur);
1 by brian
clean slate
50
    else
641.4.1 by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls
51
      strcpy(buff,path);			/* Return org file name */
1 by brian
clean slate
52
  }
53
  else
1366.1.6 by Siddharth Prakash Singh
some more sprintf --> snprintf
54
    snprintf(buff, sizeof(buff), "%s%s",own_path_prefix,path);
641.4.1 by Toru Maesaka
First pass of replacing MySQL's my_stpcpy() with appropriate libc calls
55
  strcpy(to,buff);
51.3.22 by Jay Pipes
Final round of removal of DBUG in mysys/, including Makefile
56
  return(to);
1 by brian
clean slate
57
} /* my_load_path */
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
58
59
} /* namespace internal */
60
} /* namespace drizzled */