1 #include <exec/types.h>
5 LP1(300, LONG , CVa2i, \
7 , RexxSysBase, 0, 0, 0, 0, 0, 0)
9 #define CVi2az(__p0, __p1, __p2) \
10 LP3(318, LONG , CVi2az, \
14 , RexxSysBase, 0, 0, 0, 0, 0, 0)
17 #include <proto/exec.h>
18 #include <proto/rexxsyslib.h>
19 #include <rexx/errors.h>
20 #include <aros/asmcall.h>
21 #include "locale_intern.h"
22 #include <proto/locale.h>
28 static LONG
rxGetCatalogStr(struct LocaleBase
*LocaleBase
,
29 struct Locale
*locale
, struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
32 GetCatalogStr((struct Catalog
*)CVa2i(rxmsg
->rm_Args
[1]),
33 atol(rxmsg
->rm_Args
[2]), rxmsg
->rm_Args
[3]);
34 return strlen(*resstr
);
37 static LONG
rxGetLocaleStr(struct LocaleBase
*LocaleBase
,
38 struct Locale
*locale
, struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
40 *resstr
= GetLocaleStr(locale
, atol(rxmsg
->rm_Args
[1]));
41 return strlen(*resstr
);
44 static LONG
rxOpenCatalog(struct LocaleBase
*LocaleBase
,
45 struct Locale
*locale
, struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
48 OpenCatalog(locale
, rxmsg
->rm_Args
[1], OC_BuiltInLanguage
,
49 (ULONG
) rxmsg
->rm_Args
[2], OC_Version
, atol(rxmsg
->rm_Args
[3]),
51 return CVi2az(*resstr
, (LONG
) cat
, 12);
54 static LONG
rxCloseCatalog(struct LocaleBase
*LocaleBase
,
55 struct Locale
*locale
, struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
57 CloseCatalog((struct Catalog
*)CVa2i(rxmsg
->rm_Args
[1]));
61 static LONG
rxStrnCmp(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
62 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
65 StrnCmp(locale
, rxmsg
->rm_Args
[1], rxmsg
->rm_Args
[2], -1,
66 atol(rxmsg
->rm_Args
[3]));
88 static LONG
rxConvToLower(struct LocaleBase
*LocaleBase
,
89 struct Locale
*locale
, struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
91 *resstr
[0] = (UBYTE
) ConvToLower(locale
, *rxmsg
->rm_Args
[1]);
95 static LONG
rxConvToUpper(struct LocaleBase
*LocaleBase
,
96 struct Locale
*locale
, struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
98 *resstr
[0] = (UBYTE
) ConvToUpper(locale
, *rxmsg
->rm_Args
[1]);
102 static LONG
rxIsAlpha(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
103 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
105 if (IsAlpha(locale
, *rxmsg
->rm_Args
[1]))
112 static LONG
rxIsSpace(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
113 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
115 if (IsSpace(locale
, *rxmsg
->rm_Args
[1]))
122 static LONG
rxIsDigit(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
123 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
125 if (IsDigit(locale
, *rxmsg
->rm_Args
[1]))
132 static LONG
rxIsGraph(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
133 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
135 if (IsGraph(locale
, *rxmsg
->rm_Args
[1]))
142 static LONG
rxIsAlNum(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
143 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
145 if (IsAlNum(locale
, *rxmsg
->rm_Args
[1]))
152 static LONG
rxIsCntrl(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
153 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
155 if (IsCntrl(locale
, *rxmsg
->rm_Args
[1]))
162 static LONG
rxIsLower(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
163 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
165 if (IsLower(locale
, *rxmsg
->rm_Args
[1]))
172 static LONG
rxIsPunct(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
173 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
175 if (IsPunct(locale
, *rxmsg
->rm_Args
[1]))
182 static LONG
rxIsUpper(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
183 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
185 if (IsUpper(locale
, *rxmsg
->rm_Args
[1]))
192 static LONG
rxIsPrint(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
193 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
195 if (IsPrint(locale
, *rxmsg
->rm_Args
[1]))
202 static LONG
rxIsXDigit(struct LocaleBase
*LocaleBase
, struct Locale
*locale
,
203 struct RexxMsg
*rxmsg
, STRPTR
* resstr
)
205 if (IsXDigit(locale
, *rxmsg
->rm_Args
[1]))
214 CONST_STRPTR FuncName
;
215 LONG(*Function
) (struct LocaleBase
*, struct Locale
*,
216 struct RexxMsg
*, STRPTR
*);
220 /* MUST be alphabetically sorted! */
221 struct dispentry disptable
[] = {
222 {"CLOSECATALOG", rxCloseCatalog
, 1},
223 {"CONVTOLOWER", rxConvToLower
, 1},
224 {"CONVTOUPPER", rxConvToUpper
, 1},
225 {"GETCATALOGSTR", rxGetCatalogStr
, 3},
226 {"GETLOCALESTR", rxGetLocaleStr
, 1}, /*** NEW ***/
227 {"ISALNUM", rxIsAlNum
, 1},
228 {"ISALPHA", rxIsAlpha
, 1},
229 {"ISCNTRL", rxIsCntrl
, 1},
230 {"ISDIGIT", rxIsDigit
, 1},
231 {"ISGRAPH", rxIsGraph
, 1},
232 {"ISLOWER", rxIsLower
, 1},
233 {"ISPRINT", rxIsPrint
, 1},
234 {"ISPUNCT", rxIsPunct
, 1},
235 {"ISSPACE", rxIsSpace
, 1},
236 {"ISUPPER", rxIsUpper
, 1},
237 {"ISXDIGIT", rxIsXDigit
, 1},
238 {"OPENCATALOG", rxOpenCatalog
, 3},
239 {"STRNCMP", rxStrnCmp
, 3}
242 int dispcomp(const void *name
, const void *dispentry
)
244 return stricmp(name
, ((const struct dispentry
*)dispentry
)->FuncName
);
248 /*****************************************************************************
252 AROS_LH1(ULONG
, RexxHost
,
255 AROS_LHA(struct RexxMsg
*, rxmsg
, A0
),
258 struct LocaleBase
*, LocaleBase
, 5, Locale
)
261 locale.library rexxhost interface
263 *****************************************************************************/
268 struct Locale
*locale
=
269 (struct Locale
*)IntLB(LocaleBase
)->lb_CurrentLocale
;
270 struct dispentry
*dispentry
;
273 STRPTR argstr
= resbuf
;
277 if (!rxmsg
|| !IsRexxMsg(rxmsg
) || !(rxmsg
->rm_Action
& RXFUNC
)
278 || !rxmsg
->rm_Args
[0])
282 bsearch(rxmsg
->rm_Args
[0], disptable
,
283 sizeof(disptable
) / sizeof(struct dispentry
),
284 sizeof(struct dispentry
), dispcomp
)))
286 if ((rxmsg
->rm_Action
& RXARGMASK
) != dispentry
->NumArgs
)
289 reslen
= dispentry
->Function(LocaleBase
, locale
, rxmsg
, &argstr
);
291 if (!(argstr
= CreateArgstring(argstr
, reslen
)))
295 REG_A0
= (ULONG
) argstr
;
297 #error register a0 must be set to argstr before returning...