Commit 2671de1b 2671de1b56501d14d8f54f8608a580af48f513d4 by Sergey Poznyakoff

(_url_path_init): Moved from ../url_path.c

1 parent 417a1a49
...@@ -255,3 +255,44 @@ _url_mbox_init (url_t url) ...@@ -255,3 +255,44 @@ _url_mbox_init (url_t url)
255 return 0; 255 return 0;
256 } 256 }
257 257
258 static void
259 url_path_destroy (url_t url ARG_UNUSED)
260 {
261 }
262
263 int
264 _url_path_init (url_t url)
265 {
266 const char *name = url_to_string (url);
267 const char *path;
268
269 /* reject the obvious */
270 if (name == NULL || *name == '\0')
271 return EINVAL;
272
273 mu_scheme_autodetect_p (name, &path);
274 name = strdup (path);
275 free (url->name);
276 url->name = name;
277
278 /* TYPE */
279 url->_destroy = url_path_destroy;
280
281 /* SCHEME */
282 url->scheme = strdup (MU_PATH_SCHEME);
283 if (url->scheme == NULL)
284 {
285 url_path_destroy (url);
286 return ENOMEM;
287 }
288
289 /* PATH */
290 url->path = strdup (name);
291 if (url->path == NULL)
292 {
293 url_path_destroy (url);
294 return ENOMEM;
295 }
296
297 return 0;
298 }
......