+// forbidden value int=-269488145 double=-1.54947e+231 bool=239
+const char SeqAlloc::DFT_CHAR_VAR=-17;//0xEF
+
+constexpr unsigned NB_BITS = 6;
+
+constexpr unsigned char TAB[64]={46, 61, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122};
+
+unsigned char BitAtPosSimple(char val, std::size_t bitPos)
+{
+ return (val >> bitPos) & 0x1;
+}
+
+unsigned char BitAtPos(char pt0, char pt1, std::size_t bitPos)
+{
+ if(bitPos<8)
+ return BitAtPosSimple(pt0,bitPos);
+ else
+ return BitAtPosSimple(pt1,bitPos-8);
+}
+
+unsigned char ChunkInternal(char pt0, char pt1, std::size_t startBitIdInByte)
+{
+ unsigned char ret(0);
+ for(unsigned i = 0; i<NB_BITS; ++i)
+ {
+ ret |= BitAtPos(pt0,pt1,startBitIdInByte+i);
+ ret <<= 1;
+ }
+ ret >>= 1;
+ return ret;
+}
+
+unsigned char ChunkAtPos(const char *pt, std::size_t len, std::size_t posChunk)
+{
+ std::size_t startByte((posChunk*NB_BITS)/8);
+ std::size_t startBitIdInByte((posChunk*NB_BITS)%8);
+ char pt1(startByte!=len-1?pt[startByte+1]:pt[startByte]);
+ return ChunkInternal(pt[startByte],pt1,startBitIdInByte);
+}
+
+std::size_t OnOff(std::size_t i)
+{
+ if(i!=0)
+ return 1;
+ return 0;
+}
+
+std::string YACS::ENGINE::ToBase64(const std::string& bytes)
+{//64 == 2**6
+ const char *bytesPt(bytes.c_str());
+ std::size_t input_len(bytes.size());
+ std::size_t input_len_bit(input_len*8);
+ std::size_t nb_chunks( input_len_bit/NB_BITS + OnOff((NB_BITS - input_len_bit%NB_BITS)%NB_BITS) );
+ std::string ret(nb_chunks,'\0');
+ for(std::size_t i=0;i<nb_chunks;++i)
+ {
+ unsigned char cp(ChunkAtPos(bytesPt,input_len, i));
+ ret[i] = TAB[cp];
+ }
+ return ret;
+}
+
+constexpr unsigned MAX_VAL_TAB2=123;
+
+constexpr unsigned NOT_OK_VAL = 128;
+
+constexpr unsigned char TAB2[MAX_VAL_TAB2] = { NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 0, NOT_OK_VAL, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 1, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, NOT_OK_VAL, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 };
+
+unsigned char BitAtPosSimple2(char val, std::size_t bitPos)
+{
+ return ( val >> (5-bitPos) ) & 0x1;
+}
+
+char BitAtPosOnChunk(char pt0, char pt1, std::size_t bitPos)
+{
+ if(bitPos<6)
+ return BitAtPosSimple2(pt0,bitPos);
+ else
+ return BitAtPosSimple2(pt1,bitPos-6);
+}
+
+unsigned char CheckEntry(char c)
+{
+ if( ((unsigned) c) < MAX_VAL_TAB2 )
+ {
+ unsigned char ret(TAB2[(unsigned char)c]);
+ if(ret != NOT_OK_VAL)
+ return ret;
+ throw YACS::Exception("Invalid character found !");
+ }
+ throw YACS::Exception("Invalid character found !");
+}
+
+char ByteInternal(char c0, char c1, std::size_t startBitIdInByte)
+{
+ unsigned char ret(0);
+ char ct0(CheckEntry(c0)),ct1(CheckEntry(c1));
+ for(int i = 7; i>=0; --i)
+ {
+ ret |= BitAtPosOnChunk(ct0,ct1,startBitIdInByte+i);
+ if(i!=0)
+ ret <<= 1;
+ }
+ return ret;
+}
+
+char ByteAtPos(const char *chunckPt, std::size_t bytePos)
+{
+ std::size_t startChunk((bytePos*8)/NB_BITS);
+ std::size_t startBitId((bytePos*8)%NB_BITS);
+ return ByteInternal(chunckPt[startChunk],chunckPt[startChunk+1],startBitId);
+}
+
+std::string YACS::ENGINE::FromBase64(const std::string& bytes)
+{
+ std::size_t nb_chunks(bytes.size());
+ const char *chunckPt(bytes.c_str());
+ std::size_t nb_bytes_output((nb_chunks*NB_BITS)/8);
+ std::string ret(nb_bytes_output,'\0');
+ for(std::size_t i = 0; i<nb_bytes_output; ++i)
+ {
+ ret[i] = ByteAtPos(chunckPt,i);
+ }
+ return ret;
+}
+
+/*!
+ * Method used at load time in case of non base64 bytes in input (a throw during decoding). If so, the input bytes is returned.
+ */
+std::string YACS::ENGINE::FromBase64Safe(const std::string& bytes)
+{
+ try
+ {
+ return FromBase64(bytes);
+ }
+ catch(const YACS::Exception& e)
+ {
+ return bytes;
+ }
+}
+
+StringOnHeap::StringOnHeap(const char *val):_str(strdup(val)),_len(strlen(val)),_dealloc(0)
+{
+}
+
+StringOnHeap::StringOnHeap(const char *val, std::size_t len):_dealloc(0),_len(len)