~ubuntu-branches/ubuntu/quantal/uclibc/quantal

« back to all changes in this revision

Viewing changes to libc/stdlib/canonicalize.c

  • Committer: Bazaar Package Importer
  • Author(s): Hector Oron
  • Date: 2011-06-11 03:06:20 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110611030620-ywjfvyuqvrpsm282
Tags: 0.9.32-1
* New upstream release
* Add myself as maintainer
* Bump standards version 
* Add Vcs-Git, Vcs-Browser and Homepage fields
* Add watch file 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * canonicalize.c -- Return a malloc'd string containing the canonical
 
3
 * absolute name of the named file.  The last file name component need
 
4
 * not exist, and may be a symlink to a nonexistent file.
 
5
 * Copyright (C) 2009 STMicroelectronics
 
6
 * Author: Salvatore Cro <salvatore.cro@st.com>
 
7
 *
 
8
 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
 
9
 */
 
10
 
 
11
#include <stdlib.h>
 
12
#include <limits.h>
 
13
 
 
14
#ifdef __USE_GNU
 
15
 
 
16
#ifndef PATH_MAX
 
17
# ifdef _POSIX_VERSION
 
18
#  define PATH_MAX _POSIX_PATH_MAX
 
19
# else
 
20
#  ifdef MAXPATHLEN
 
21
#   define PATH_MAX MAXPATHLEN
 
22
#  else
 
23
#   define PATH_MAX 1024
 
24
#  endif
 
25
# endif
 
26
#endif
 
27
 
 
28
char * canonicalize_file_name (const char *name)
 
29
{
 
30
        char *buf = (char *) malloc(PATH_MAX);
 
31
 
 
32
        if(unlikely(buf == NULL))
 
33
                return NULL;
 
34
 
 
35
        *buf='\0';
 
36
        return realpath (name, buf);
 
37
}
 
38
#endif