5 * ----------------------------------------------------------------------
6 * This code is (C) Copyright 1993,1994 by Frank Munkert.
8 * This software may be freely distributed and redistributed for
9 * non-commercial purposes, provided this notice is included.
10 * ----------------------------------------------------------------------
13 * 07-Jul-02 sheutlin various changes when porting to AROS
14 * - global variables are now in a struct Globals *global
15 * - moved structure to path.h
18 #include <proto/exec.h>
19 #include <exec/memory.h>
27 #include "clib_stuff.h"
29 /* Append p_name to path list: */
31 t_path_list
Append_Path_List(t_path_list p_list
, char *p_name
) {
34 if (!(node
= AllocMem (sizeof (*node
), MEMF_PUBLIC
)))
38 if (!(node
->name
= AllocMem (StrLen (p_name
) + 1, MEMF_PUBLIC
)))
40 FreeMem (node
, sizeof (*node
));
44 StrCpy (node
->name
, p_name
);
45 node
->next
= Copy_Path_List (p_list
, FALSE
);
50 t_path_list
Copy_Path_List (t_path_list p_src
, int p_strip
)
52 t_path_node
*node
, *start
;
57 start
= p_strip
? p_src
->next
: p_src
;
59 for (node
= start
; node
; node
= node
->next
) {
66 void Free_Path_List(t_path_list p_list
) {
67 t_path_node
*node
, *next
;
72 for (node
= p_list
; node
; node
= next
)
75 if (--node
->references
== 0)
77 FreeMem (node
->name
, StrLen (node
->name
) + 1);
78 FreeMem (node
, sizeof (*node
));
83 t_bool Path_Name_From_Path_List
84 (t_path_list p_list
, char *p_buffer
, int p_buffer_length
)
91 StrCpy (p_buffer
, ":");
95 /* calculate length: */
96 for (len
=1, node
=p_list
; node
; node
= node
->next
)
97 len
+= StrLen (node
->name
) + 1;
99 if (len
> p_buffer_length
)
102 for (node
=p_list
; node
; node
= node
->next
)
107 p_buffer
+ len
- StrLen (node
->name
) - 1,
110 p_buffer
[len
-1] = (node
== p_list
) ? 0 : '/';
111 len
-= StrLen (node
->name
) + 1;