~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_path.c

  • Committer: Monty Taylor
  • Date: 2008-07-02 14:35:48 UTC
  • mto: This revision was merged to the branch mainline in revision 51.
  • Revision ID: monty@inaugust.com-20080702143548-onj30ry0sugr01uw
Removed all references to THREAD.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
#include "mysys_priv.h"
17
 
#include <mystrings/m_string.h>
18
 
#include "my_static.h"
 
17
#include <m_string.h>
19
18
 
20
19
static char *find_file_in_path(char *to,const char *name);
21
20
 
35
34
{
36
35
  char *start, *end, *prog;
37
36
  size_t to_length;
 
37
  DBUG_ENTER("my_path");
38
38
 
39
39
  start=to;                                     /* Return this */
40
40
  if (progname && (dirname_part(to, progname, &to_length) ||
42
42
                   ((prog=getenv("_")) != 0 &&
43
43
                    dirname_part(to, prog, &to_length))))
44
44
  {
45
 
    intern_filename(to,to);
 
45
    VOID(intern_filename(to,to));
46
46
    if (!test_if_hard_path(to))
47
47
    {
48
48
      if (!my_getwd(curr_dir,FN_REFLEN,MYF(0)))
49
 
        bchange((unsigned char*) to, 0, (unsigned char*) curr_dir, strlen(curr_dir), strlen(to)+1);
 
49
        bchange((uchar*) to, 0, (uchar*) curr_dir, strlen(curr_dir), strlen(to)+1);
50
50
    }
51
51
  }
52
52
  else
60
60
      end= (char*) "/my/";
61
61
#endif
62
62
    }
63
 
    intern_filename(to,end);
64
 
    to= strchr(to, '\0');
 
63
    VOID(intern_filename(to,end));
 
64
    to=strend(to);
65
65
    if (to != start && to[-1] != FN_LIBCHAR)
66
66
      *to++ = FN_LIBCHAR;
67
 
    my_stpcpy(to,own_pathname_part);
 
67
    VOID(strmov(to,own_pathname_part));
68
68
  }
69
 
  return(start);
 
69
  DBUG_PRINT("exit",("to: '%s'",start));
 
70
  DBUG_RETURN(start);
70
71
} /* my_path */
71
72
 
72
73
 
73
74
        /* test if file without filename is found in path */
74
 
        /* Returns to if found and to has dirpart if found, else NULL */
 
75
        /* Returns to if found and to has dirpart if found, else NullS */
75
76
 
76
77
#define PATH_SEP ':'
77
78
 
81
82
  const char *ext="";
82
83
 
83
84
  if (!(path=getenv("PATH")))
84
 
    return NULL;
 
85
    return NullS;
85
86
  dir[0]=FN_LIBCHAR; dir[1]=0;
86
87
#ifdef PROGRAM_EXTENSION
87
88
  if (!fn_ext(name)[0])
92
93
  {
93
94
    if (path != pos)
94
95
    {
95
 
      strxmov(my_stpncpy(to,path,(uint) (pos-path)),dir,name,ext,NULL);
 
96
      strxmov(strnmov(to,path,(uint) (pos-path)),dir,name,ext,NullS);
96
97
      if (!access(to,F_OK))
97
98
      {
98
99
        to[(uint) (pos-path)+1]=0;      /* Return path only */
100
101
      }
101
102
    }
102
103
  }
103
 
  return NULL;                          /* File not found */
 
104
  return NullS;                         /* File not found */
104
105
}