68 static const char cb64[] =
69 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
75 return OREF_NULLSTRING;
78 size_t outputLength = (inputLength / 3) * 4;
79 if (inputLength % 3 > 0)
88 while (inputLength > 0)
91 for (i = 0; i < 3; i++)
95 inc[i] = *source & 0xff;
107 *destination = cb64[ inc[0] >> 2 ];
109 *destination = cb64[ ((inc[0] & 0x03) << 4) | ((inc[1] & 0xf0) >> 4) ];
111 *destination = (char) (buflen > 1 ? cb64[ ((inc[1] & 0x0f) << 2) | ((inc[2] & 0xc0) >> 6) ] :
'=');
113 *destination = (char) (buflen > 2 ? cb64[ inc[2] & 0x3f ] :
'=');
131 static const char cb64[] =
132 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
136 if (inputLength == 0)
138 return OREF_NULLSTRING;
140 if (inputLength % 4 > 0) {
146 size_t outputLength = (inputLength / 4) * 3;
147 if (*(source + inputLength - 1) ==
'=')
151 if (*(source + inputLength - 2) ==
'=')
159 while (inputLength != 0)
161 for (i = 0; i < 4; i++)
163 for (j = 0; j < 64; j++)
165 if (*(cb64 + j) == *(source + i))
173 if (*(source + i) ==
'=' && inputLength <= 4) {
186 *destination = (char)(j << 2);
189 *destination |= (char)(j >> 4);
191 *destination = (char)(j << 4);
194 *destination |= (char)(j >> 2);
196 *destination = (char)(j << 6);
199 *destination |= (char)j;
225 if (InputLength == 0)
227 Retval = OREF_NULLSTRING;
236 while (InputLength-- != 0)
269 return numberstring->
d2xD2c(_length,
true);
286 return numberstring->
d2xD2c(_length,
false);
298 return OREF_NULLSTRING;
314 return this->
x2dC2d(_length,
false);
335 size_t NibblePosition;
340 size_t CurrentDigits;
374 if (*StringPtr & 0x80)
405 BytePosition = ResultSize / 2;
407 NibblePosition = ResultSize % 2;
409 ResultSize = (BytePosition + NibblePosition);
421 if ((NibblePosition != 0 &&
423 *StringPtr & 0x08) ||
424 (NibblePosition == 0 &&
442 while (TempSize-- != 0)
445 *Scan = *Scan ^ 0xff;
451 while (TempSize-- != 0)
467 if (NibblePosition != 0)
479 HighDigit = Accumulator - 1;
489 DecLength = (Accumulator - HighDigit);
490 if (DecLength > CurrentDigits)
509 DecLength = (Accumulator - HighDigit);
510 if (DecLength > CurrentDigits)
523 DecLength = (Accumulator - HighDigit);
524 TempLength = DecLength;
525 Scan = HighDigit + 1;
533 ResultSize = DecLength;
545 memcpy(Scan, Accumulator - DecLength + 1, DecLength);
566 Retval = OREF_NULLSTRING;
588 memset(Nibble,
'0', 4);
608 return this->
x2dC2d(_length,
true);
628 Retval = OREF_NULLSTRING;
648 memcpy(Destination, Nibble, 4);
void reportException(wholenumber_t error)
RexxBuffer * new_buffer(size_t s)
size_t optionalLengthArgument(RexxObject *o, size_t d, size_t p)
#define Error_Incorrect_method_d2x
#define Error_Incorrect_method_d2c
#define Error_Incorrect_method_x2dbig
#define Error_Incorrect_method_invbase64
#define Error_Incorrect_method_c2dbig
RexxString * raw_string(stringsize_t l)
char IntToHexDigit(int n)
size_t RexxEntry StringLength(RexxThreadContext *c, RexxStringObject s)
static char * addToBaseTen(int, char *, char *)
RexxString * d2xD2c(RexxObject *, bool)
static char * multiplyBaseTen(char *, char *)
const char * getStringData()
RexxString * encodeBase64()
RexxString * d2x(RexxInteger *)
RexxNumberString * numberString()
RexxString * d2c(RexxInteger *)
RexxString * x2dC2d(RexxInteger *, bool)
RexxString * x2d(RexxInteger *)
RexxString * c2d(RexxInteger *)
RexxString * decodeBase64()
static void unpackNibble(int Val, char *p)
static size_t validateSet(const char *String, size_t Length, const char *Set, int Modulus, bool Hex)
static RexxString * packHex(const char *String, size_t StringLength)
static char packNibble(const char *String)
static int hexDigitToInt(char ch)
static size_t chGetSm(char *Destination, const char *Source, size_t Length, size_t Count, const char *Set, size_t *ScannedSize)