Replaced deprecated variables CONTRIBDIR, BINDIR and
[AROS-Contrib.git] / rexx / src / rxconv.c
blob83d24c54acb215726b6a7c76b7beadd6051ab9f8
1 /*
2 * $Header$
3 * $Log$
4 * Revision 1.1 2001/04/04 05:43:39 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.3 1999/11/26 13:13:47 bnv
8 * Changed: Something in the formatting of code.
10 * Revision 1.2 1999/03/15 15:22:23 bnv
11 * Changed the type cast in Lxrange
13 * Revision 1.1 1998/07/02 17:34:50 bnv
14 * Initial revision
18 #include <math.h>
20 #include <lerror.h>
21 #include <lstring.h>
23 #include <rexx.h>
24 #include <rxdefs.h>
26 /* --------------------------------------------------------------- */
27 /* BITAND(string1[,[string2][,pad]]) */
28 /* --------------------------------------------------------------- */
29 /* BITOR(string1[,[string2][,pad]]) */
30 /* --------------------------------------------------------------- */
31 /* BITXOR(string1[,[string2][,pad]]) */
32 /* --------------------------------------------------------------- */
33 void
34 R_SoSoC( const int func )
36 char pad=0;
37 bool usepad;
38 PLstr a2;
39 Lstr nullstr;
41 if (!IN_RANGE(1,ARGN,3)) Lerror(ERR_INCORRECT_CALL,0);
43 must_exist(1);
45 if (exist(2))
46 a2 = ARG2;
47 else {
48 LINITSTR(nullstr);
49 a2 = &nullstr;
52 if (exist(3)) {
53 usepad = TRUE;
54 get_pad(3,pad);
55 } else
56 usepad = FALSE;
58 switch (func) {
59 case f_bitand:
60 Lbitand(ARGR,ARG1,a2,usepad,pad);
61 break;
63 case f_bitor:
64 Lbitor(ARGR,ARG1,a2,usepad,pad);
65 break;
67 case f_bitxor:
68 Lbitxor(ARGR,ARG1,a2,usepad,pad);
69 break;
71 default:
72 Lerror(ERR_INTERPRETER_FAILURE,0);
73 } /* switch */
74 } /* R_SoSoC */
76 /* --------------------------------------------------------------- */
77 /* C2D(string[,n]) */
78 /* --------------------------------------------------------------- */
79 /* X2D(hex-string[,n]) */
80 /* --------------------------------------------------------------- */
81 void
82 R_SoI ( const int func )
84 long n;
85 if (!IN_RANGE(1,ARGN,2)) Lerror(ERR_INCORRECT_CALL,0);
86 must_exist(1);
87 get_oi(2,n);
89 switch (func) {
90 case f_c2d:
91 Lc2d(ARGR,ARG1,n);
92 break;
94 case f_x2d:
95 Lx2d(ARGR,ARG1,n);
96 break;
98 default:
99 Lerror(ERR_INTERPRETER_FAILURE,0);
100 } /* switch */
101 } /* R_SoI */
103 /* --------------------------------------------------------------- */
104 /* D2C(wholenumber[,n]) */
105 /* --------------------------------------------------------------- */
106 /* D2X(wholenumber[,n]) */
107 /* --------------------------------------------------------------- */
108 void
109 R_IoI ( const int func )
111 long n;
113 if (!IN_RANGE(1,ARGN,2)) Lerror(ERR_INCORRECT_CALL,0);
114 must_exist(1);
115 get_oiv(2,n,-1);
117 switch (func) {
118 case f_d2c:
119 Ld2c(ARGR,ARG1,n);
120 break;
122 case f_d2x:
123 Ld2x(ARGR,ARG1,n);
124 break;
126 default:
127 Lerror(ERR_INTERPRETER_FAILURE,0);
128 } /* switch */
129 } /* R_IoI */
131 /* --------------------------------------------------------------- */
132 /* FORMAT(number(,(before)(,(after)(,(expp)(,expt))))) */
133 /* --------------------------------------------------------------- */
134 void
135 R_format( )
137 long before, after, expp, expt;
139 if (!IN_RANGE(1,ARGN,5)) Lerror(ERR_INCORRECT_CALL,0);
140 must_exist(1);
142 get_oi0(2,before);
143 get_oi0(3,after);
144 get_oi0(4,expp);
145 get_oi0(5,expt);
147 Lformat(ARGR,ARG1,before,after,expp,expt);
148 } /* R_format */
150 /* --------------------------------------------------------------- */
151 /* TRUNC(number(,n)) */
152 /* --------------------------------------------------------------- */
153 void
154 R_trunc( )
156 long n;
158 if (!IN_RANGE(1,ARGN,2)) Lerror(ERR_INCORRECT_CALL,0);
159 must_exist(1);
160 get_oi0(2,n);
162 Ltrunc(ARGR,ARG1,n);
163 } /* R_trunc */
165 /* --------------------------------------------------------------- */
166 /* XRANGE([start][,end]) */
167 /* --------------------------------------------------------------- */
168 void
169 R_xrange( )
171 unsigned int start, stop;
173 if (ARGN>2) Lerror(ERR_INCORRECT_CALL,0);
174 if (exist(1)) {
175 L2STR(ARG1);
176 if (LLEN(*ARG1)!=1) Lerror(ERR_INCORRECT_CALL,0);
177 start = (unsigned)LSTR(*ARG1)[0] & 0xFF;
178 } else
179 start = 0;
181 if (exist(2)) {
182 L2STR(ARG2);
183 if (LLEN(*ARG2)!=1) Lerror(ERR_INCORRECT_CALL,0);
184 stop = (unsigned)LSTR(*ARG2)[0] & 0xFF;
185 } else
186 stop = 255;
188 Lxrange(ARGR,(byte)start,(byte)stop);
189 } /* R_xrange */