2 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
5 Desc: utility internal function __path_u2a()
9 #include "__arosc_privdata.h"
15 static const char *__path_devstuff_u2a(const char *path
);
16 static void __path_normalstuff_u2a(const char *path
, char *buf
);
18 /*****************************************************************************
24 const char *__path_u2a(
30 Translates an unix-style path into an AmigaDOS one.
33 upath - Unix-style path to translate into an AmigaDOS-style equivalent.
36 A pointer to a string containing the AmigaDOS-style path, or NULL in
39 The pointer is valid only until next call to this function, so if
40 you need to call this function recursively, you must save the string
41 pointed to by the pointer before calling this function again.
44 This function is for private usage by system code. Do not use it
51 ******************************************************************************/
53 struct aroscbase
*aroscbase
= __GM_GetBase();
56 /* Does the path really need to be converted? */
57 if (!aroscbase
->acb_doupath
)
67 /* Some scripts (config.guess) try to access /.attbin
68 which is MacOS-specific thing. Block it. */
69 if (!strncmp(upath
, "/.attbin", 8))
76 First see whether the path is in the /dev/#? form and,
77 if so, if it's handled internally
79 newpath
= __path_devstuff_u2a(upath
);
82 /* Else, convert it normally */
83 newpath
= realloc_nocopy(aroscbase
->acb_apathbuf
, strlen(upath
) + 1);
91 aroscbase
->acb_apathbuf
= (char *)newpath
;
92 __path_normalstuff_u2a(upath
, aroscbase
->acb_apathbuf
);
98 /*****************************************************************************
104 const char *__path_a2u(
110 Translates an AmigaDOS-style path into an unix one.
113 apath - AmigaDOS-style path to translate into an unix-style equivalent.
116 A pointer to a string containing the unix-style path, or NULL in
119 The pointer is valid only until next call to this function, so if
120 you need to call this function recursively, you must save the string
121 pointed to by the pointer before calling this function again.
124 This function is for private usage by system code. Do not use it
131 ******************************************************************************/
133 struct aroscbase
*aroscbase
= __GM_GetBase();
134 const char *old_apath
= apath
;
135 char ch
, *upath
, *old_upath
;
155 if (!aroscbase
->acb_doupath
)
158 while ((ch
= *apath
++))
169 old_upath
= realloc_nocopy(aroscbase
->acb_apathbuf
, 1 + size
+ 1);
170 if (old_upath
== NULL
)
176 aroscbase
->acb_apathbuf
= old_upath
;
184 register char ch
= apath
[0];
215 (--old_upath
)[0] = '/';
235 upath
[0] = '.'; upath
[1] = '.'; upath
[2] = '/'; upath
+= 3;
255 static const char *__path_devstuff_u2a(const char *path
)
258 Translate the various /dev/#? most used files into the AROS equivalent.
259 Use a tree-like handmade search to speed things up
262 if (path
[0] == '/' && path
[1] == 'd' && path
[2] == 'e' && path
[3] == 'v')
266 if (path
[5] == 'n' && path
[6] == 'u' && path
[7] == 'l' && path
[8] == 'l' && path
[9] == '\0')
269 if (path
[5] == 'z' && path
[6] == 'e' && path
[7] == 'r' && path
[8] == 'o' && path
[9] == '\0')
272 if (path
[5] == 's' && path
[6] == 't' && path
[7] == 'd')
274 if (path
[8] == 'i' && path
[9] == 'n' && path
[10] == '\0')
277 if (path
[8] == 'o' && path
[9] == 'u' && path
[10] == 't' && path
[11] == '\0')
280 if (path
[8] == 'e' && path
[9] == 'r' && path
[10] == 'r' && path
[11] == '\0')
295 static void __path_normalstuff_u2a(const char *path
, char *buf
)
297 register char dir_sep
= '\0';
298 register int makevol
= 0;
310 while (path
[0] == '/')
318 register char ch
= path
[0];
374 if (ch
== '/' || ch
== '\0')