/[path-sandbox]/tags/sandbox_1_2_13/canonicalize.c
Gentoo

Diff of /tags/sandbox_1_2_13/canonicalize.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 29 Revision 30
44 canonical name is SB_PATH_MAX chars or more, returns null with `errno' 44 canonical name is SB_PATH_MAX chars or more, returns null with `errno'
45 set to ENAMETOOLONG; if the name fits in fewer than SB_PATH_MAX chars, 45 set to ENAMETOOLONG; if the name fits in fewer than SB_PATH_MAX chars,
46 returns the name in RESOLVED. If the name cannot be resolved and 46 returns the name in RESOLVED. If the name cannot be resolved and
47 RESOLVED is non-NULL, it contains the path of the first component 47 RESOLVED is non-NULL, it contains the path of the first component
48 that cannot be resolved. If the path can be resolved, RESOLVED 48 that cannot be resolved. If the path can be resolved, RESOLVED
49 holds the same value as the value returned. */ 49 holds the same value as the value returned. */
50 50
51/* Modified: 19 Aug 2002; Martin Schlemmer <azarah@gentoo.org> 51/* Modified: 19 Aug 2002; Martin Schlemmer <azarah@gentoo.org>
52 * 52 *
53 * Cleaned up unneeded stuff, and change so that it will not 53 * Cleaned up unneeded stuff, and change so that it will not
54 * resolve symlinks. Also prepended a 'e' to functions that 54 * resolve symlinks. Also prepended a 'e' to functions that
55 * I did not rip out. 55 * I did not rip out.
56 * 56 *
57 */ 57 */
58 58
59char * 59static char *
60erealpath(const char *name, char *resolved) 60erealpath(const char *name, char *resolved)
61{ 61{
62 char *rpath, *dest; 62 char *rpath, *dest;
63 const char *start, *end, *rpath_limit; 63 const char *start, *end, *rpath_limit;
64 long int path_max; 64 long int path_max;
65 65
66 if (name == NULL) { 66 if (name == NULL) {
67 /* As per Single Unix Specification V2 we must return an error if 67 /* As per Single Unix Specification V2 we must return an error if
68 either parameter is a null pointer. We extend this to allow 68 either parameter is a null pointer. We extend this to allow
69 the RESOLVED parameter to be NULL in case the we are expected to 69 the RESOLVED parameter to be NULL in case the we are expected to
70 allocate the room for the return value. */ 70 allocate the room for the return value. */
71 __set_errno(EINVAL); 71 __set_errno(EINVAL);
72 return NULL; 72 return NULL;
73 } 73 }
108 for (start = end = name; *start; start = end) { 108 for (start = end = name; *start; start = end) {
109 /* Skip sequence of multiple path-separators. */ 109 /* Skip sequence of multiple path-separators. */
110 while (*start == '/') 110 while (*start == '/')
111 ++start; 111 ++start;
112 112
113 /* Find end of path component. */ 113 /* Find end of path component. */
114 for (end = start; *end && *end != '/'; ++end) 114 for (end = start; *end && *end != '/'; ++end)
115 /* Nothing. */ ; 115 /* Nothing. */ ;
116 116
117 if (end - start == 0) 117 if (end - start == 0)
118 break; 118 break;

Legend:
Removed from v.29  
changed lines
  Added in v.30

  ViewVC Help
Powered by ViewVC 1.1.20