Commit dcd50df5 dcd50df50fb73f9eea1042d2b1ac1b06cd5ece70 by Sergey Poznyakoff

Removed declaration of util_normalize_path().

1 parent b8f2274d
...@@ -80,6 +80,7 @@ ...@@ -80,6 +80,7 @@
80 #include <mailutils/parse822.h> 80 #include <mailutils/parse822.h>
81 #include <mailutils/registrar.h> 81 #include <mailutils/registrar.h>
82 #include <mailutils/stream.h> 82 #include <mailutils/stream.h>
83 #include <mailutils/mutil.h>
83 84
84 #ifndef _PATH_MAILDIR 85 #ifndef _PATH_MAILDIR
85 # define _PATH_MAILDIR "/usr/spool/mail" 86 # define _PATH_MAILDIR "/usr/spool/mail"
...@@ -232,7 +233,6 @@ extern int util_parse_internal_date __P((char *date, time_t *timep)); ...@@ -232,7 +233,6 @@ extern int util_parse_internal_date __P((char *date, time_t *timep));
232 extern int util_parse_822_date __P((char *date, time_t *timep)); 233 extern int util_parse_822_date __P((char *date, time_t *timep));
233 extern int util_parse_ctime_date __P((const char *date, time_t *timep)); 234 extern int util_parse_ctime_date __P((const char *date, time_t *timep));
234 extern char *util_strcasestr __P((const char *haystack, const char *needle)); 235 extern char *util_strcasestr __P((const char *haystack, const char *needle));
235 extern char *util_normalize_path __P((char *path, const char *delim));
236 extern int util_parse_attributes __P((char *items, char **save, int *flags)); 236 extern int util_parse_attributes __P((char *items, char **save, int *flags));
237 237
238 #ifdef __cplusplus 238 #ifdef __cplusplus
......
...@@ -115,71 +115,6 @@ util_tilde_expansion (const char *ref, const char *delim) ...@@ -115,71 +115,6 @@ util_tilde_expansion (const char *ref, const char *delim)
115 return mu_tilde_expansion (ref, delim, homedir); 115 return mu_tilde_expansion (ref, delim, homedir);
116 } 116 }
117 117
118 /* util_normalize_path: convert pathname containig relative paths specs (../)
119 into an equivalent absolute path. Strip trailing delimiter if present,
120 unless it is the only character left. E.g.:
121
122 /home/user/../smith --> /home/smith
123 /home/user/../.. --> /
124
125 FIXME: delim is superfluous. The function deals with unix filesystem
126 paths, so delim should be always "/" */
127 char *
128 util_normalize_path (char *path, const char *delim)
129 {
130 int len;
131 char *p;
132
133 if (!path)
134 return path;
135
136 len = strlen (path);
137
138 /* Empty string is returned as is */
139 if (len == 0)
140 return path;
141
142 /* delete trailing delimiter if any */
143 if (len && path[len-1] == delim[0])
144 path[len-1] = 0;
145
146 /* Eliminate any /../ */
147 for (p = strchr (path, '.'); p; p = strchr (p, '.'))
148 {
149 if (p > path && p[-1] == delim[0])
150 {
151 if (p[1] == '.' && (p[2] == 0 || p[2] == delim[0]))
152 /* found */
153 {
154 char *q, *s;
155
156 /* Find previous delimiter */
157 for (q = p-2; *q != delim[0] && q >= path; q--)
158 ;
159
160 if (q < path)
161 break;
162 /* Copy stuff */
163 s = p + 2;
164 p = q;
165 while ((*q++ = *s++))
166 ;
167 continue;
168 }
169 }
170
171 p++;
172 }
173
174 if (path[0] == 0)
175 {
176 path[0] = delim[0];
177 path[1] = 0;
178 }
179
180 return path;
181 }
182
183 /* Get the absolute path. */ 118 /* Get the absolute path. */
184 /* NOTE: Path is allocated and must be free()d by the caller. */ 119 /* NOTE: Path is allocated and must be free()d by the caller. */
185 char * 120 char *
...@@ -193,7 +128,7 @@ util_getfullpath (char *name, const char *delim) ...@@ -193,7 +128,7 @@ util_getfullpath (char *name, const char *delim)
193 free (p); 128 free (p);
194 p = s; 129 p = s;
195 } 130 }
196 return util_normalize_path (p, delim); 131 return mu_normalize_path (p, delim);
197 } 132 }
198 133
199 /* Return in set an allocated array contain (n) numbers, for imap messsage set 134 /* Return in set an allocated array contain (n) numbers, for imap messsage set
......