13
13
along with this program; if not, write to the Free Software
14
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18
#include "drizzled/internal/my_sys.h"
16
#include "mysys/mysys_priv.h"
17
#include <mystrings/m_string.h>
18
#include "my_static.h"
22
#include "drizzled/internal/m_string.h"
23
#include "my_static.h"
30
23
static char * expand_tilde(char * *path);
31
static size_t system_filename(char * to, const char *from);
34
27
remove unwanted chars from dirname
232
225
if (path[0][0] == FN_LIBCHAR)
233
226
return home_dir; /* ~/ expanded to home */
235
struct passwd *user_entry;
230
struct passwd *user_entry;
237
if (!(str=strchr(*path,FN_LIBCHAR)))
238
str= strchr(*path, '\0');
239
save= *str; *str= '\0';
240
user_entry=getpwnam(*path);
246
return user_entry->pw_dir;
232
if (!(str=strchr(*path,FN_LIBCHAR)))
233
str= strchr(*path, '\0');
234
save= *str; *str= '\0';
235
user_entry=getpwnam(*path);
241
return user_entry->pw_dir;
288
285
/* Used before system command's like open(), create() .. */
289
286
/* Returns used length of to; total length should be FN_REFLEN */
291
static size_t system_filename(char * to, const char *from)
288
size_t system_filename(char * to, const char *from)
290
#ifndef FN_C_BEFORE_DIR
293
291
return strlen(strncpy(to,from,FN_REFLEN-1));
294
/* change 'dev:lib/xxx' to 'dev:[lib]xxx' */
295
/* change 'dev:xxx' to 'dev:xxx' */
296
/* change './xxx' to 'xxx' */
297
/* change './lib/' or lib/ to '[.lib]' */
298
/* change '/x/y/z to '[x.y]x' */
299
/* change 'dev:/x' to 'dev:[000000]x' */
303
char * to_pos,from_pos,pos;
304
char buff[FN_REFLEN];
307
(void) strcpy(buff,from); /* If to == from */
309
if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skip device part */
312
to_pos= strncpy(to,from_pos,(size_t) (pos-from_pos));
319
if (from_pos[0] == FN_CURLIB && from_pos[1] == FN_LIBCHAR)
320
from_pos+=2; /* Skip './' */
321
if (strchr(from_pos,FN_LIBCHAR))
323
*(to_pos++) = FN_C_BEFORE_DIR;
324
if (strstr(from_pos,FN_ROOTDIR) == from_pos)
326
from_pos+=strlen(FN_ROOTDIR); /* Actually +1 but... */
327
if (! strchr(from_pos,FN_LIBCHAR))
328
{ /* No dir, use [000000] */
329
to_pos= strcpy(to_pos,FN_C_ROOT_DIR)+strlen(FN_C_ROOT_DIR);
334
*(to_pos++)=FN_C_DIR_SEP; /* '.' gives current dir */
336
while ((pos=strchr(from_pos,FN_LIBCHAR)))
339
*(to_pos++)=FN_C_DIR_SEP; /* Add '.' between dirs */
340
if (strstr(from_pos,FN_PARENTDIR) == from_pos &&
341
from_pos+strlen(FN_PARENTDIR) == pos) {
342
to_pos= strcpy(to_pos,FN_C_PARENT_DIR); /* Found '../' */
343
to_pos+= strlen(FN_C_PARENT_DIR);
347
to_pos= strncpy(to_pos,from_pos,(size_t) (pos-from_pos));
348
to_pos+= strlen(to_pos);
352
*(to_pos++)=FN_C_AFTER_DIR;
355
strcpy(to_pos, from_pos);
294
359
} /* system_filename */