~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/mf_pack.cc

  • Committer: Monty Taylor
  • Date: 2009-10-06 19:40:45 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20091006194045-ojptaq2sx6ck6q63
No more server_includes.h in headers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
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
 
 
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
#include "mysys/mysys_priv.h"
 
17
#include <mystrings/m_string.h>
 
18
#include "my_static.h"
 
19
#ifdef HAVE_PWD_H
20
20
#include <pwd.h>
21
 
 
22
 
#include <drizzled/internal/m_string.h>
23
 
#include "my_static.h"
24
 
 
25
 
namespace drizzled
26
 
{
27
 
namespace internal
28
 
{
 
21
#endif
29
22
 
30
23
static char * expand_tilde(char * *path);
31
 
static size_t system_filename(char * to, const char *from);
 
24
 
32
25
 
33
26
/*
34
27
  remove unwanted chars from dirname
50
43
    #  length of new name
51
44
*/
52
45
 
53
 
static size_t cleanup_dirname(char *to, const char *from)
 
46
size_t cleanup_dirname(register char *to, const char *from)
54
47
{
55
 
  size_t length;
56
 
  char * pos;
57
 
  const char * from_ptr;
58
 
  char * start;
 
48
  register size_t length;
 
49
  register char * pos;
 
50
  register const char * from_ptr;
 
51
  register char * start;
59
52
  char parent[5],                               /* for "FN_PARENTDIR" */
60
53
       buff[FN_REFLEN+1],*end_parentdir;
61
54
 
231
224
{
232
225
  if (path[0][0] == FN_LIBCHAR)
233
226
    return home_dir;                    /* ~/ expanded to home */
234
 
  char *str,save;
235
 
  struct passwd *user_entry;
 
227
#ifdef HAVE_GETPWNAM
 
228
  {
 
229
    char *str,save;
 
230
    struct passwd *user_entry;
236
231
 
237
 
  if (!(str=strchr(*path,FN_LIBCHAR)))
238
 
    str= strchr(*path, '\0');
239
 
  save= *str; *str= '\0';
240
 
  user_entry=getpwnam(*path);
241
 
  *str=save;
242
 
  endpwent();
243
 
  if (user_entry)
244
 
  {
245
 
    *path=str;
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);
 
236
    *str=save;
 
237
    endpwent();
 
238
    if (user_entry)
 
239
    {
 
240
      *path=str;
 
241
      return user_entry->pw_dir;
 
242
    }
247
243
  }
 
244
#endif
248
245
  return NULL;
249
246
}
250
247
 
288
285
        /* Used before system command's like open(), create() .. */
289
286
        /* Returns used length of to; total length should be FN_REFLEN */
290
287
 
291
 
static size_t system_filename(char * to, const char *from)
 
288
size_t system_filename(char * to, const char *from)
292
289
{
293
290
  return strlen(strncpy(to,from,FN_REFLEN-1));
294
291
} /* system_filename */
309
306
  (void) strcpy(to + to_length,from+length);
310
307
  return (to);
311
308
} /* intern_filename */
312
 
 
313
 
} /* namespace internal */
314
 
} /* namespace drizzled */