Ejemplo n.º 1
0
    explicit ShareData_Recv(InStream & stream, rdp_mppc_dec * dec = nullptr)
    //==============================================================================
    : CheckShareData_Recv(stream)
    , share_id(stream.in_uint32_le())
    , pad1(stream.in_uint8())
    , streamid(stream.in_uint8())
    , len(stream.in_uint16_le())
    , pdutype2(stream.in_uint8())
    , compressedType(stream.in_uint8())
    , compressedLen(stream.in_uint16_le())
    , payload([&stream, dec, this]() {
          if (this->compressedType & PACKET_COMPRESSED) {
              if (!dec) {
                  LOG(LOG_INFO, "ShareData_Recv: got unexpected compressed share data");
                  throw Error(ERR_SEC);
              }

              const uint8_t * rdata;
              uint32_t        rlen;

              dec->decompress(stream.get_data()+stream.get_offset(), stream.in_remain(),
                  this->compressedType, rdata, rlen);

              return InStream(rdata, 0, rlen);
          }
          else {
              return InStream(stream.get_current(), stream.in_remain());
          }
      }())
    // BEGIN CONSTRUCTOR
    {
        //LOG( LOG_INFO, "ShareData_Recv: pdutype2=%u len=%u compressedLen=%u payload_size=%u"
        //   , this->pdutype2, this->len, this->compressedLen, this->payload.size());
        stream.in_skip_bytes(stream.in_remain());
    } // END CONSTRUCTOR
Ejemplo n.º 2
0
    explicit ShareControl_Recv(InStream & stream)
    : totalLength([&stream]() {
        if (!stream.in_check_rem(2+2)){
            LOG(LOG_ERR,
                "Truncated [4: ShareControl packet] , remains=%zu", stream.in_remain());
            throw Error(ERR_SEC);
        }
        return stream.in_uint16_le();
    }())
    , pduType(stream.in_uint16_le() & 0xF)
    , PDUSource([&stream, this]() {
        if (this->pduType == PDUTYPE_DEACTIVATEALLPDU && this->totalLength == 4) {
            // should not happen
            // but DEACTIVATEALLPDU seems to be broken on windows 2000
            return static_cast<uint16_t>(0);
        }
        return stream.in_uint16_le();
    }())
    , payload([&stream, this]() {
        if (this->pduType == PDUTYPE_DEACTIVATEALLPDU && this->totalLength == 4) {
            // should not happen
            // but DEACTIVATEALLPDU seems to be broken on windows 2000
            return InStream(stream.get_current(), 0);
        }

        if (this->totalLength < 6) {
            LOG(LOG_ERR, "ShareControl packet too short totalLength=%u pduType=%u mcs_channel=%u",
                this->totalLength, this->pduType, this->PDUSource);
            throw Error(ERR_SEC);
        }

        if (!stream.in_check_rem(this->totalLength - 6)) {
            LOG(LOG_ERR, "Truncated ShareControl packet, need=%u remains=%zu",
                this->totalLength - 6,
                stream.in_remain());
            throw Error(ERR_SEC);
        }
        return InStream(stream.get_current(), this->totalLength - 6);
    }())
    // body of constructor
    {
        if (this->totalLength == 0x8000) {
            LOG(LOG_ERR, "Expected ShareControl header, got flowMarker");
            throw Error(ERR_SEC);
        }
        stream.in_skip_bytes(this->payload.get_capacity());
    }
Ejemplo n.º 3
0
    bool next_chunk() {
        try {
            {
                auto const buf_sz = FileToGraphic::HEADER_SIZE;
                unsigned char buf[buf_sz];
                auto * p = buf;
                this->trans->recv(&p, buf_sz);
                InStream header(buf);
                this->chunk_type  = header.in_uint16_le();
                this->chunk_size  = header.in_uint32_le();
                this->chunk_count = header.in_uint16_le();
            }

            if (this->chunk_size > 65536) {
                LOG(LOG_INFO,"chunk_size (%d) > 65536", this->chunk_size);
                return false;
            }
            this->stream = InStream(this->stream_buf, 0);   // empty stream
            if (this->chunk_size - FileToGraphic::HEADER_SIZE > 0) {
                auto * p = this->stream_buf;
                this->trans->recv(&p, this->chunk_size - FileToGraphic::HEADER_SIZE);
                this->stream = InStream(this->stream_buf, p - this->stream_buf);
            }
        }
        catch (Error const & e) {
            if (e.id == ERR_TRANSPORT_OPEN_FAILED) {
                throw;
            }

            if (this->verbose) {
                LOG(LOG_INFO,"receive error %u : end of transport", e.id);
            }
            // receive error, end of transport
            return false;
        }

        return true;
    }
Ejemplo n.º 4
0
    std::string GetSha256ForFile(std::string Filename)
    {
        SHA256 SHA;
#ifndef WIN32
        std::ifstream InStream(Filename.c_str());
#else
        std::ifstream InStream(Utility::Widen(Filename).c_str());
#endif
        unsigned char tmpbuf[256];

        if (!InStream.is_open())
            return "";

        while (!InStream.eof())
        {
            InStream.read((char*)tmpbuf, 256);
            size_t cnt = InStream.gcount();

            SHA.add(tmpbuf, cnt);
        }

        return std::string(SHA.getHash());
    }
bool CFuzzyMembershipFunction::Open (const char* name)
{
  std::filebuf FileBuffer;
  
  FileBuffer.open(name,std::ios::in | std::ios::binary);
  if (FileBuffer.is_open())
  {
    std::istream InStream(&FileBuffer);
    bool Result = Read(InStream);
    FileBuffer.close();
    return Result;
  }

  return false;
}
Ejemplo n.º 6
0
OSG_BEGIN_NAMESPACE

void getLine(const std::string& Text, UInt32 TextPos, Int32& LineNumber, Int32& LineStartPos)
{
    std::istringstream InStream(Text);

    std::string Line;
    LineNumber = 1;
    LineStartPos = 0;
    while(std::getline(InStream, Line) && TextPos > LineStartPos+Line.size())
    {
        LineStartPos += Line.size() + 1;
        ++LineNumber;
    }
}
Ejemplo n.º 7
0
void SettingsManager::LoadFile()
{

    QFileInfo CheckFile(FilePath);

    if (CheckFile.exists() && CheckFile.isFile())
    {
        QFile ExistingFile(FilePath);
        ExistingFile.open(QIODevice::ReadOnly);

        QTextStream InStream(&ExistingFile);
        while(!InStream.atEnd())
        {
            QStringList Line = InStream.readLine().split(",");

            Set(Line[0], Line[1]);
        }

        ExistingFile.close();
    }
    else
    {
        QFile NewFile(FilePath);
        NewFile.open(QIODevice::WriteOnly);

        QTextStream OutStream(&NewFile);

        OutStream   << "RememberPos,0\n" //remember where the window is pos + size
                    << "Size,0;0\n"
                    << "Pos,0;0\n"
                    << "HideWin,0\n"
                    << "LockPos,0\n"
                    << "HideBar,0\n"
                    << "AutoLoad,1\n"
                    << "LinkHistory,10\n"
                    << "HotkeyOpen,ctrl+shift+Right\n"
                    << "HotkeyClose,ctrl+shift+Left\n"
                    << "HotkeyAuto,ctrl+shift+Down\n";

        NewFile.close();

        LoadFile();
    }
}
Ejemplo n.º 8
0
    std::string GetSha256ForFile(std::filesystem::path Filename)
    {
        SHA256 SHA;
        std::ifstream InStream(Filename.string());
        unsigned char tmpbuf[256];

        if (!InStream.is_open())
            return "";

        while (!InStream.eof())
        {
            InStream.read((char*)tmpbuf, 256);
            size_t cnt = InStream.gcount();

            SHA.add(tmpbuf, cnt);
        }

        return std::string(SHA.getHash());
    }
Ejemplo n.º 9
0
BOOL TDrawDocument::Open(int /*mode*/, const char far* path)
{
//	if(ecg)
//		delete ecg;
	ecg = new Tecg();

  if (path)
	 SetDocPath(path);
  if (GetDocPath())
  {
	 TInStream* is = InStream(ofRead);
	 if (!is)
		return FALSE;

	*is >> *ecg;
	 delete is;
  }
  SetDirty(FALSE);
  return TRUE;
}
Ejemplo n.º 10
0
 void do_recv(char ** pbuffer, size_t len) override {
     size_t total_len = 0;
     while (total_len < len){
         size_t remaining = in_stream.in_remain();
         if (remaining >= (len - total_len)){
             in_stream.in_copy_bytes(*pbuffer + total_len, len - total_len);
             *pbuffer += len;
             return;
         }
         in_stream.in_copy_bytes(*pbuffer + total_len, remaining);
         total_len += remaining;
         switch (this->chunk_type){
         case PARTIAL_IMAGE_CHUNK:
         {
             const size_t header_sz = 8;
             char header_buf[header_sz];
             InStream header(header_buf);
             auto * p = header_buf;
             this->trans->recv(&p, header_sz);
             this->chunk_type = header.in_uint16_le();
             this->chunk_size = header.in_uint32_le();
             this->chunk_count = header.in_uint16_le();
             this->in_stream = InStream(this->buf, this->chunk_size - 8);
             p = this->buf;
             this->trans->recv(&p, this->chunk_size - 8);
         }
         break;
         case LAST_IMAGE_CHUNK:
             LOG(LOG_ERR, "Failed to read embedded image from WRM (transport closed)");
             throw Error(ERR_TRANSPORT_NO_MORE_DATA);
         default:
             LOG(LOG_ERR, "Failed to read embedded image from WRM");
             throw Error(ERR_TRANSPORT_READ_FAILED);
         }
     }
 }
Ejemplo n.º 11
0
//Basic Init, create the font, backbuffer, etc
WINDOW *curses_init(void)
{
   // _windows = new WINDOW[20];         //initialize all of our variables
    lastchar=-1;
    inputdelay=-1;

    int fontsize = 16;
    std::string typeface;
    int map_fontwidth = 8;
    int map_fontheight = 16;
    int map_fontsize = 16;
    std::string map_typeface;
    int overmap_fontwidth = 8;
    int overmap_fontheight = 16;
    int overmap_fontsize = 16;
    std::string overmap_typeface;
    bool fontblending;

    std::ifstream jsonstream(FILENAMES["fontdata"].c_str(), std::ifstream::binary);
    if (jsonstream.good()) {
        JsonIn json(jsonstream);
        JsonObject config = json.get_object();
        // fontsize, fontblending, map_* are ignored in wincurse.
        fontwidth = config.get_int("fontwidth", fontwidth);
        fontheight = config.get_int("fontheight", fontheight);
        typeface = config.get_string("typeface", typeface);
        jsonstream.close();
    } else { // User fontdata is missed. Try to load legacy fontdata.
        // Get and save all values. With unused.
        std::ifstream InStream(FILENAMES["legacy_fontdata"].c_str(), std::ifstream::binary);
        if(InStream.good()) {
            JsonIn jIn(InStream);
            JsonObject config = jIn.get_object();
            fontwidth = config.get_int("fontwidth", fontwidth);
            fontheight = config.get_int("fontheight", fontheight);
            fontsize = config.get_int("fontsize", fontsize);
            typeface = config.get_string("typeface", typeface);
            map_fontwidth = config.get_int("map_fontwidth", fontwidth);
            map_fontheight = config.get_int("map_fontheight", fontheight);
            map_fontsize = config.get_int("map_fontsize", fontsize);
            map_typeface = config.get_string("map_typeface", typeface);
            overmap_fontwidth = config.get_int("overmap_fontwidth", fontwidth);
            overmap_fontheight = config.get_int("overmap_fontheight", fontheight);
            overmap_fontsize = config.get_int("overmap_fontsize", fontsize);
            overmap_typeface = config.get_string("overmap_typeface", typeface);
            InStream.close();
            // Save legacy as user fontdata.
            assure_dir_exist(FILENAMES["config_dir"]);
            std::ofstream OutStream(FILENAMES["fontdata"].c_str(), std::ofstream::binary);
            if(!OutStream.good()) {
                DebugLog( D_ERROR, DC_ALL ) << "Can't save user fontdata file.\n"
                << "Check permissions for: " << FILENAMES["fontdata"].c_str();
                return NULL;
            }
            JsonOut jOut(OutStream, true); // pretty-print
            jOut.start_object();
            jOut.member("fontblending", fontblending);
            jOut.member("fontwidth", fontwidth);
            jOut.member("fontheight", fontheight);
            jOut.member("fontsize", fontsize);
            jOut.member("typeface", typeface);
            jOut.member("map_fontwidth", map_fontwidth);
            jOut.member("map_fontheight", map_fontheight);
            jOut.member("map_fontsize", map_fontsize);
            jOut.member("map_typeface", map_typeface);
            jOut.member("overmap_fontwidth", overmap_fontwidth);
            jOut.member("overmap_fontheight", overmap_fontheight);
            jOut.member("overmap_fontsize", overmap_fontsize);
            jOut.member("overmap_typeface", overmap_typeface);
            jOut.end_object();
            OutStream << "\n";
            OutStream.close();
        } else {
            DebugLog( D_ERROR, DC_ALL ) << "Can't load fontdata files.\n"
            << "Check permissions for:\n" << FILENAMES["legacy_fontdata"].c_str() << "\n"
            << FILENAMES["fontdata"].c_str() << "\n";
            return NULL;
        }
    }

    halfwidth=fontwidth / 2;
    halfheight=fontheight / 2;
    WindowWidth= OPTIONS["TERMINAL_X"] * fontwidth;
    WindowHeight = OPTIONS["TERMINAL_Y"] * fontheight;

    WinCreate();    //Create the actual window, register it, etc
    timeBeginPeriod(1); // Set Sleep resolution to 1ms
    CheckMessages();    //Let the message queue handle setting up the window

    WindowDC   = GetDC(WindowHandle);
    backbuffer = CreateCompatibleDC(WindowDC);

    BITMAPINFO bmi = BITMAPINFO();
    bmi.bmiHeader.biSize         = sizeof(BITMAPINFOHEADER);
    bmi.bmiHeader.biWidth        = WindowWidth;
    bmi.bmiHeader.biHeight       = -WindowHeight;
    bmi.bmiHeader.biPlanes       = 1;
    bmi.bmiHeader.biBitCount     = 8;
    bmi.bmiHeader.biCompression  = BI_RGB; // Raw RGB
    bmi.bmiHeader.biSizeImage    = WindowWidth * WindowHeight * 1;
    bmi.bmiHeader.biClrUsed      = 16; // Colors in the palette
    bmi.bmiHeader.biClrImportant = 16; // Colors in the palette
    backbit = CreateDIBSection(0, &bmi, DIB_RGB_COLORS, (void**)&dcbits, NULL, 0);
    DeleteObject(SelectObject(backbuffer, backbit));//load the buffer into DC

    // Load private fonts
    if (SetCurrentDirectoryW(L"data\\font")){
        WIN32_FIND_DATA findData;
        for (HANDLE findFont = FindFirstFileW(L".\\*", &findData); findFont != INVALID_HANDLE_VALUE; )
        {
            if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)){ // Skip folders
                AddFontResourceExW(findData.cFileName, FR_PRIVATE,NULL);
            }
            if (!FindNextFile(findFont, &findData)){
                FindClose(findFont);
                break;
            }
        }
        SetCurrentDirectoryW(L"..\\..");
    }

    // Use desired font, if possible
    font = CreateFontW(fontheight, fontwidth, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
                      DEFAULT_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
                      PROOF_QUALITY, FF_MODERN, widen(typeface).c_str());

    SetBkMode(backbuffer, TRANSPARENT);//Transparent font backgrounds
    SelectObject(backbuffer, font);//Load our font into the DC
//    WindowCount=0;

    init_colors();

    mainwin = newwin(OPTIONS["TERMINAL_Y"],OPTIONS["TERMINAL_X"],0,0);
    return mainwin;   //create the 'stdscr' window and return its ref
}
Ejemplo n.º 12
0
void DlgAbout::DoInitDialog() {
    QString FName,Text;
    QFile   File;

    if (ApplicationConfig->CurrentLanguage!="fr") FName=ApplicationConfig->StartingPath+QDir::separator()+QString("changelog-en.txt");
        else FName=ApplicationConfig->StartingPath+QDir::separator()+QString("changelog-fr.txt");
    File.setFileName(FName);
    if (File.open(QIODevice::ReadOnly|QIODevice::Text)) {
        QTextStream InStream(&File);
        InStream.setCodec("UTF-8");
        Text=InStream.readAll();
        ui->ChangelogED->setText(Text);
        File.close();
    } else {
        ui->tabWidget->removeTab(5);
    }

    Text.clear();
    if (ApplicationConfig->CurrentLanguage!="en") {
        FName=ApplicationConfig->UserConfigPath+QString("%1_LOCALEVERSION.TXT").arg(ApplicationConfig->CurrentLanguage);
        File.setFileName(FName);
        if (!File.exists()) {
            FName=ApplicationConfig->UserConfigPath+QString("%1_VERSION.TXT").arg(ApplicationConfig->CurrentLanguage);
            File.setFileName(FName);
        }
        if (!File.exists()) {
            FName=ApplicationConfig->UserConfigPath+QString("LOCALEVERSION.TXT");
            File.setFileName(FName);
        }
        if (!File.exists()) {
            FName=ApplicationConfig->UserConfigPath+QString("VERSION.TXT");
            File.setFileName(FName);
        }
        if (File.open(QIODevice::ReadOnly|QIODevice::Text)) {
            while (!File.atEnd()) {
                QString Line=File.readLine();
                if (Line.indexOf("=")<0) Line=QApplication::translate("DlgAbout","Interface translation version: ")+Line+"\n\ten\t100%\n"; else {
                    if (Line.indexOf("to translate")) Line.replace("to translate",QApplication::translate("DlgAbout","to translate"));
                    Line="\t"+Line;
                    Line.replace(" = ","\t");
                }
                Text.append(Line);
            }
            File.close();
        }
    }

    if (ApplicationConfig->CurrentLanguage!="en") {
        FName=ApplicationConfig->UserConfigPath+QString("%1_WIKIVERSION.TXT").arg(ApplicationConfig->CurrentLanguage);
        File.setFileName(FName);
        if (!File.exists()) {
            FName=ApplicationConfig->UserConfigPath+QString("WIKIVERSION.TXT");
            File.setFileName(FName);
        }
        if (File.open(QIODevice::ReadOnly|QIODevice::Text)) {
            while (!File.atEnd()) {
                QString Line=File.readLine();
                if (Line.indexOf("=")<0) {
                    if (!Text.isEmpty()) Text.append("\n");
                    Line=QApplication::translate("DlgAbout","WIKI translation version: ")+Line+"\n\ten\t100%\n";
                } else {
                    if (Line.indexOf("to translate")) Line.replace("to translate",QApplication::translate("DlgAbout","to translate"));
                    Line="\t"+Line;
                    Line.replace(" = ","\t");
                }
                Text.append(Line);
            }
            File.close();
        }
    }
    if (!Text.isEmpty()) ui->TranslationED->setText(Text); else ui->tabWidget->removeTab(4);

    FName=QString("clipart")+QDir::separator()+QString("openclipart-0.18-svgonly-readme.txt");
    File.setFileName(FName);
    if (File.open(QIODevice::ReadOnly|QIODevice::Text)) {
        Text=File.readAll();
        ui->OpenclipartED->setText(Text);
        File.close();
    } else {
        ui->tabWidget->removeTab(3);
    }
    FName=QString("background")+QDir::separator()+QString("texturemate")+QDir::separator()+QString("readme.txt");
    File.setFileName(FName);
    if (File.open(QIODevice::ReadOnly|QIODevice::Text)) {
        QString Text=File.readAll();
        ui->TexturemateED->setText(Text);
        File.close();
    } else {
        ui->tabWidget->removeTab(2);
    }
    QFile File2("authors.txt");
    if (File2.open(QIODevice::ReadOnly|QIODevice::Text)) {
        QString Text=File2.readAll();
        ui->CreditsED->setText(Text);
        File2.close();
    } else {
        ui->tabWidget->removeTab(1);
    }

    ui->ApplicationReleaseLabel->setText(QString("%1 (%2)").arg(CurrentAppName).arg(CurrentAppVersion));
    ui->ApplicationNameLabel->setText(APPLICATION_NAME);
    ui->tabWidget->setCurrentIndex(0);
}
Ejemplo n.º 13
0
    // Constructor
    // Params :
    //    - file_path : path to the font definition file (*.fv1)
    //==============================================================================
    explicit Font(const char * file_path) {
    //==============================================================================
        int fd;
        int b;
         // we start at space, no glyph for chars below 32
        int file_size;

        TODO("Temporary disabling font to avoid useless messages in watchdog");
//        LOG(LOG_INFO, "Reading font file %s", file_path);
        // RAZ of font chars table

        // Does font definition file exist and is it accessible ?
        if (access(file_path, F_OK)) {
            LOG(LOG_ERR,
                "create: error font file [%s] does not exist\n",
                file_path);
            goto ErrorReadingFontFile;
        }

        // Retrieves system stats about the file
        struct stat st;
        if (stat(file_path, &st)) {
            LOG(LOG_ERR, "create: can't stat file [%s]\n", file_path);
            goto ErrorReadingFontFile;
        }
        // Is file empty ?
        if (st.st_size < 1) {
            LOG(LOG_ERR, "create: empty font file [%s]\n", file_path);
            goto ErrorReadingFontFile;
        }

        // Allocate a buffer to read the whole file into
        file_size = st.st_size;

        if (-1 == (fd = open(file_path, O_RDONLY))){
            LOG(LOG_ERR, "create: can't open font file [%s] for reading\n", file_path);
            goto ErrorReadingFontFile;
        }

        {
            std::size_t size_to_read = file_size;
            std::size_t const stream_buf_sz = 8192;
            char stream_buf[stream_buf_sz];

            // Read header
            // -----------
            while ((b = read(fd, stream_buf, stream_buf_sz)) < 0) {
                if (b >= 0){
                    break;
                }
                if ((errno == EAGAIN)||(errno == EINTR)){
                    continue;
                }
                LOG(LOG_ERR,"create: error reading font file [%s] error: %s\n", file_path, strerror(errno));
                goto ErrorReadingFontFile;
            }
            InStream stream(stream_buf, b);
            size_to_read -= b;
            if (size_to_read == 0){
                close(fd);
                fd = -1;
            }

            // Extract font info from the buffer
            //----------------------------------
            stream.in_skip_bytes(4);                       // >>> 4 bytes for FNT1 (dropped)
            stream.in_copy_bytes(this->name, 32);          // >>> 32 bytes for Font Name
            this->size = stream.in_uint16_le();            // >>> 2 bytes for Font Size
            TODO("temporary disabled to avoid warning in watchdog, see other TODO above to reenable later");
//            LOG(LOG_INFO, "font name <%s> size <%u>", this->name, this->size);
            this->style = stream.in_uint16_le();           // >>> 2 bytes for Font Style
            stream.in_skip_bytes(8);                       // >>> 8 bytes for PAD (dropped)

            // Extract each character glyph
            for (int index = 32; index < NUM_GLYPHS ; index++) {
                unsigned remaining = stream.in_remain();
                if (remaining < 1024){
                    if (size_to_read > 0){
                        TODO("Create a pack_left function in stream to do this");
                        //-----------------------------------------------------
                        memmove(stream_buf, stream.get_current(), remaining);
                        //-----------------------------------------------------
                        while ((b = read(fd, stream_buf + remaining, std::min(size_to_read, stream_buf_sz - remaining))) < 0){
                            if (b >= 0){
                                break;
                            }
                            if ((errno == EAGAIN)||(errno == EINTR)){
                                continue;
                            }
                            LOG(LOG_ERR,"create: error reading font file [%s] error: %s\n", file_path, strerror(errno));
                            goto ErrorReadingFontFile;
                        }
                        stream = InStream(stream_buf, remaining + b);
                        size_to_read -= b;
                        if (size_to_read == 0){
                            close(fd);
                            fd = -1;
                        }
                    }
                    // no more remaining glyphs in file
                    if (!stream.in_check_rem(1)){
                        LOG(LOG_INFO, "Font file %s defines glyphs up to %d", file_path, index);
                        break;
                    }
                    if (!stream.in_check_rem(16)){
                        LOG(LOG_WARNING, "Font file %s defines glyphs up to %d, file looks broken", file_path, index);
                        break;
                    }
                }

//                LOG(LOG_INFO, "Reading definition for glyph %u", index);
                int width = stream.in_sint16_le(); // >>> 2 bytes for glyph width
                int height = stream.in_sint16_le(); // >>> 2 bytes for glyph height

    TODO(" baseline is always -height (seen from the code of fontdump) looks strange. It means that baseline is probably not used in current code.");

                int baseline = stream.in_sint16_le(); // >>> 2 bytes for glyph baseline
                int offset = stream.in_sint16_le(); // >>> 2 bytes for glyph offset
                int incby = stream.in_sint16_le(); // >>> 2 bytes for glyph incby
                stream.in_skip_bytes(6); // >>> 6 bytes for PAD (dropped)
                this->font_items[index] = FontChar(offset, baseline, width, height, incby);

                // Check if glyph data size make sense
                unsigned datasize = this->font_items[index].datasize();
                if (datasize > 512) { // shouldn't happen, implies broken font file
                    LOG(LOG_WARNING,
                        "Error loading font %s. Wrong size for glyph %d"
                        "width %d height %d \n", file_path, index,
                        this->font_items[index].width,
                        this->font_items[index].height);
                    // one glyph is broken but we continue with other glyphs
                    continue;
                }

                // Read the data only if there is enough space left in buffer
                if (!stream.in_check_rem(datasize)) {
                    LOG(LOG_ERR
                       , "Error loading font %s: not enough data for definition of glyph %d (expected %u, got %zu)\n"
                        , file_path, index, datasize, stream.in_remain()
                       );
                    goto ErrorReadingFontFile;
                }

                // >>> <datasize> bytes for glyph data (bitmap)
                stream.in_copy_bytes(this->font_items[index].data.get(), datasize);
            }
        }
        return;
ErrorReadingFontFile:
        LOG(LOG_ERR, "Error reading font definition file %s, exiting proxy",  file_path);
        exit(-1);
    }