Support rastport clipping rectangle for layerless rastports
[tangerine.git] / rom / dos / splitname.c
blobf5ed63b61848b3be350b95a4da9424a47edd64ed
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Split a path into pieces
6 Lang: english
7 */
8 #ifndef TEST
9 # include "dos_intern.h"
10 #else
11 # include <proto/dos.h>
12 # undef SplitName
13 # undef AROS_LH5
14 # define AROS_LH5(t,fn,a1,a2,a3,a4,a5,bt,bn,o,lib) t fn (a1,a2,a3,a4,a5)
15 # undef AROS_LHA
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
23 #endif
25 /*****************************************************************************
27 NAME */
28 #include <proto/dos.h>
30 AROS_LH5(LONG, SplitName,
32 /* SYNOPSIS */
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),
39 /* LOCATION */
40 struct DosLibrary *, DOSBase, 69, Dos)
42 /* FUNCTION
43 Split a path into parts at the position of seperator.
45 INPUTS
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
51 to 0.
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
54 be copied.
56 RESULT
57 The next position to continue for the next part or -1 if
58 there is no seperator after name+oldpos.
60 NOTES
62 EXAMPLE
63 See below.
65 BUGS
67 SEE ALSO
69 INTERNALS
71 *****************************************************************************/
73 AROS_LIBFUNC_INIT
74 AROS_LIBBASE_EXT_DECL(struct DosLibrary *,DOSBase)
76 size --;
78 name += oldpos;
80 while (*name != seperator && *name && size)
82 size --;
83 *buf++ = *name++;
84 oldpos ++;
87 *buf = 0;
89 if (*name == seperator)
90 return oldpos + 1;
92 return -1;
93 AROS_LIBFUNC_EXIT
94 } /* SplitName */
96 #ifdef TEST
98 # include <stdio.h>
99 # include <dos/dos.h>
101 # include <proto/dos.h>
103 int main (int argc, char ** argv)
105 LONG pos;
106 UBYTE buffer[256];
108 if (argc < 3)
110 fprintf (stderr, "Usage: %s <path> <seperator>\n", argv[0]);
111 return RETURN_ERROR;
114 pos=0;
118 pos = SplitName (argv[1], *(argv[2]), buffer, pos, sizeof(buffer));
120 printf ("pos = %3ld buffer = \"%s\"\n", pos, buffer);
122 while (pos != -1);
124 return RETURN_OK;
127 #endif /* TEST */