tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / rom / dos / findarg.c
blob23f945ec4999d33751a4486948ae18bdef5eab79
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
8 #include <proto/utility.h>
9 #include "dos_intern.h"
11 /*****************************************************************************
13 NAME */
14 #include <proto/dos.h>
16 AROS_LH2(LONG, FindArg,
18 /* SYNOPSIS */
19 AROS_LHA(CONST_STRPTR, template, D1),
20 AROS_LHA(CONST_STRPTR, keyword, D2),
22 /* LOCATION */
23 struct DosLibrary *, DOSBase, 134, Dos)
25 /* FUNCTION
26 Search for keyword in the template string.
27 Abbreviations are handled.
29 INPUTS
30 template - template string to be searched
31 keyword - keyword to search for
33 RESULT
34 Index of the keyword or -1 if not found.
36 NOTES
38 EXAMPLE
40 BUGS
42 SEE ALSO
44 INTERNALS
46 *****************************************************************************/
48 AROS_LIBFUNC_INIT
50 LONG count=0;
51 CONST_STRPTR key;
53 /* Loop over template */
54 for(;;)
56 /* Compare key to template */
57 key=keyword;
58 for(;;)
60 UBYTE lkey;
62 /* If the keyword has ended check the template */
63 if(!*key)
65 if(!*template||*template=='='||*template=='/'||*template==',')
66 /* The template has ended, too. Return count. */
67 return count;
68 /* The template isn't finished. Stop comparison. */
69 break;
71 /* If the two differ stop comparison. */
72 lkey=ToLower(*key);
73 if(lkey!=ToLower(*template))
74 break;
75 /* Go to next character */
76 key++;
77 template++;
79 /* Find next keyword in template */
80 for(;;)
82 if(!*template)
83 return -1;
84 if(*template=='=')
86 /* Alias found */
87 template++;
88 break;
90 if(*template==',')
92 /* Next item found */
93 template++;
94 count++;
95 break;
97 template++;
100 AROS_LIBFUNC_EXIT
101 } /* FindArg */