2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Split a path into pieces
9 # include "dos_intern.h"
11 # include <proto/dos.h>
14 # define AROS_LH5(t,fn,a1,a2,a3,a4,a5,bt,bn,o,lib) t fn (a1,a2,a3,a4,a5)
16 # define AROS_LHA(t,n,r) t n
17 # undef AROS_LIBFUNC_INIT
18 # define AROS_LIBFUNC_INIT
19 # undef AROS_LIBBASE_EXT_DECL
20 # define AROS_LIBBASE_EXT_DECL(bt,bn)
21 # undef AROS_LIBFUNC_EXIT
22 # define AROS_LIBFUNC_EXIT
25 /*****************************************************************************
28 #include <proto/dos.h>
30 AROS_LH5(LONG
, SplitName
,
33 AROS_LHA(STRPTR
, name
, D1
),
34 AROS_LHA(ULONG
, seperator
, D2
),
35 AROS_LHA(STRPTR
, buf
, D3
),
36 AROS_LHA(LONG
, oldpos
, D4
),
37 AROS_LHA(LONG
, size
, D5
),
40 struct DosLibrary
*, DOSBase
, 69, Dos
)
43 Split a path into parts at the position of seperator.
46 name - Split this path
47 seperator - Split it at this seperator
48 buf - Copy the current part into this buffer
49 oldpos - Begin at this place with the search for seperator.
50 If you call this function for the first time, set it
52 size - The size of the buffer. If the current part of the
53 path is bigger than size-1, only size-1 bytes will
57 The next position to continue for the next part or -1 if
58 there is no seperator after name+oldpos.
71 *****************************************************************************/
74 AROS_LIBBASE_EXT_DECL(struct DosLibrary
*,DOSBase
)
80 while (*name
!= seperator
&& *name
&& size
)
89 if (*name
== seperator
)
101 # include <proto/dos.h>
103 int main (int argc
, char ** argv
)
110 fprintf (stderr
, "Usage: %s <path> <seperator>\n", argv
[0]);
118 pos
= SplitName (argv
[1], *(argv
[2]), buffer
, pos
, sizeof(buffer
));
120 printf ("pos = %3ld buffer = \"%s\"\n", pos
, buffer
);