2 Copyright © 1995-2013, 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_LIBFUNC_EXIT
20 # define AROS_LIBFUNC_EXIT
23 /*****************************************************************************
26 #include <proto/dos.h>
28 AROS_LH5(LONG
, SplitName
,
31 AROS_LHA(CONST_STRPTR
, name
, D1
),
32 AROS_LHA(ULONG
, separator
, D2
),
33 AROS_LHA(STRPTR
, buf
, D3
),
34 AROS_LHA(LONG
, oldpos
, D4
),
35 AROS_LHA(LONG
, size
, D5
),
38 struct DosLibrary
*, DOSBase
, 69, Dos
)
41 Split a path into parts at the position of separator.
44 name - Split this path
45 separator - Split it at this separator
46 buf - Copy the current part into this buffer
47 oldpos - Begin at this place with the search for separator.
48 If you call this function for the first time, set it
50 size - The size of the buffer. If the current part of the
51 path is bigger than size-1, only size-1 bytes will
55 The next position to continue for the next part or -1 if
56 there is no separator after name+oldpos.
68 *****************************************************************************/
76 while (*name
!= separator
&& *name
&& size
)
85 if (*name
== separator
)
97 # include <proto/dos.h>
99 int main (int argc
, char ** argv
)
106 fprintf (stderr
, "Usage: %s <path> <separator>\n", argv
[0]);
114 pos
= SplitName (argv
[1], *(argv
[2]), buffer
, pos
, sizeof(buffer
));
116 printf ("pos = %3ld buffer = \"%s\"\n", pos
, buffer
);