Beispiel #1
0
unsigned char * GetLanguagecodeFromFile(const char *FileName)
{

   FILE  *fp;
   struct tagFontLibHeader fileHeader;
   u32    FileLength;
   unsigned char *LanguageCode=NULL;

   fp=fopen(FileName,"rb");
   if(fp==NULL)
    {
      printf("open the file failed!\n");
      goto exit;
   }
   fseek(fp,0L,SEEK_SET);

   fread(&fileHeader,sizeof(struct tagFontLibHeader),1,fp);

    if((fileHeader.magic[0] != 'U' && fileHeader.magic[0] != 'M'))
    {
        printf("Cann't support file format!\n");
        return 0;
    }

    if('M' == fileHeader.magic[0])     //mbcs 编码
    {
        printf("This is the Mbcs code!\n");
    }
    else
    {
        printf("This is the Unicode code!\n");
    }
    //对fileHeader的数据的顺序进行调整
  //  AdjustProcedure( &fileHeader.Size, &fileHeader.Size, sizeof(fileHeader.Size));
//  AdjustProcedure( &fileHeader.wCpFlag, &fileHeader.wCpFlag, sizeof(fileHeader.wCpFlag));

    printf("filesize=%08x\n",fileHeader.Size);
    printf("LanguageF=%04x\n",fileHeader.wCpFlag);



    LanguageCode=M_MallocLc(fileHeader.Size,0);
    if(NULL==LanguageCode)
        {

      fclose(fp);
      goto exit;
    }
    fseek(fp,0L,SEEK_SET);
    FileLength=fread(LanguageCode,fileHeader.Size,sizeof(unsigned char),fp);
    printf("---File--Length=%08x\n",FileLength);
//  memcpy(&fileHeader,LanguageCode,0x10);
    fclose(fp);

exit:
    return LanguageCode;
}
static void rfbProcessClientNormalMessage(rfbClientPtr cl)
{
    int n=0;
    rfbClientToServerMsg msg;
    char *str;
    int i;

//  unsigned char  keyvalue;
    u32 enc;

//   debug_printf("--In the NormalMessadge process!\n");
    if ((n = ReadExact(cl, (char *)&msg, 1)) <= 0)
    {
        debug_printf("rfbProcessClientNormalMessage: read--type-error,shutdown clien!\n");
//      delay(10);
        rfbCloseClient(cl);
        return;
    }
 //   debug_printf("--In the NormalMessadge process!--has read msg type=%d \n",msg.type);
    switch (msg.type) //根据收到的消息来对应的处理各种情况
    {

        case rfbSetPixelFormat://目前已经处理完备
            debug_printf("SetPixelFormat!\n");

            if ((n = ReadExact(cl, ((char *)&msg) + 1,
                               sz_rfbSetPixelFormatMsg - 1)) <= 0)
            {
                debug_printf("rfbProcessClientNormalMessage: read--setpixelmessage-error,shutdown client!\n");
//              delay(10000);
                rfbCloseClient(cl);
                return;
            }

            cl->format.bitsPerPixel = msg.spf.format.bitsPerPixel;
            cl->format.depth = msg.spf.format.depth;
            cl->format.bigEndian = (msg.spf.format.bigEndian ? 1 : 0);
            cl->format.trueColour = (msg.spf.format.trueColour ? 1 : 0);
            cl->format.redMax = Swap16IfLE(msg.spf.format.redMax);
            cl->format.greenMax = Swap16IfLE(msg.spf.format.greenMax);
            cl->format.blueMax = Swap16IfLE(msg.spf.format.blueMax);
            cl->format.redShift = msg.spf.format.redShift;
            cl->format.greenShift = msg.spf.format.greenShift;
            cl->format.blueShift = msg.spf.format.blueShift;

            cl->readyForSetColourMapEntries = TRUE;
            //这个是必须要处理的,因为当客户端发送的信息是颜色不是真彩色的话,必须要发送服务器的映射方法。
            debug_printf("got  the client set pixformat=%s\n",cl->host);
            showPixelFormat(&(cl->format));
    //      deug_printf("--set the client color translate begin!\n");
            rfbSetTranslateFunction(cl);
    //      debug_printf("--set the client color end!\n");

            return;

        case rfbFixColourMapEntries:

            debug_printf("rfbFixColourMapEntries!\n");

            if ((n = ReadExact(cl, ((char *)&msg) + 1,
                               sz_rfbFixColourMapEntriesMsg - 1)) <= 0) {
                debug_printf("rfbProcessClientNormalMessage: read--fixpixelmessage-error,shutdown client!\n");
                delay(10000);
                rfbCloseClient(cl);
                return;
            }
            debug_printf("FixColourMapEntries unsupported\n");
            rfbCloseClient(cl);
            return;


        case rfbSetEncodings://目前已经处理完备
        {
            //debug_printf("rfbSetEncodings!\n");


            if ((n = ReadExact(cl, ((char *)&msg) + 1,
                               sz_rfbSetEncodingsMsg - 1)) <= 0) {
                debug_printf("rfbProcessClientNormalMessage: read--rfbSetEncodings-error,shutdown client!\n");
                delay(10000);
                rfbCloseClient(cl);
                return;
            }

            msg.se.nEncodings = Swap16IfLE(msg.se.nEncodings);

            cl->preferredEncoding = -1;
            cl->useCopyRect = FALSE;
            cl->enableCursorShapeUpdates = FALSE;
            cl->enableLastRectEncoding = FALSE;

            for (i = 0; i < msg.se.nEncodings; i++) {
                if ((n = ReadExact(cl, (char *)&enc, 4)) <= 0) {
                    debug_printf("rfbProcessClientNormalMessage: read--rfbSetEncodings-error,shutdown client!\n");
                    delay(10000);
                    rfbCloseClient(cl);
                    return;
                }
                enc = Swap32IfLE(enc);

                switch (enc) {

                case rfbEncodingCopyRect:
                    debug_printf("client %s supported rfbEncodingCopyRect\n",cl->host);
                    cl->useCopyRect = TRUE;
                    break;
                case rfbEncodingRaw:
                    debug_printf("client %s supported rfbEncodingRaw\n",cl->host);
                    if (cl->preferredEncoding == -1) {
                        cl->preferredEncoding = enc;
                        debug_printf("Using raw encoding for client %s\n",
                               cl->host);
                    }
                    break;
                case rfbEncodingRRE:
                    debug_printf("client %s supported rfbEncodingRRE\n",cl->host);
                    if (cl->preferredEncoding == -1) {
                        cl->preferredEncoding = enc;
                        debug_printf("Using rre encoding for client %s\n",
                               cl->host);
                    }
                    break;
                case rfbEncodingCoRRE:
                    debug_printf("client %s supported rfbEncodingCoRRE\n",cl->host);
                    if (cl->preferredEncoding == -1) {
                        cl->preferredEncoding = enc;
                        debug_printf("Using CoRRE encoding for client %s\n",
                               cl->host);
                    }
                    break;
                case rfbEncodingHextile:
                    debug_printf("client %s supported rfbEncodingHextile\n",cl->host);
                    if (cl->preferredEncoding == -1) {
                        cl->preferredEncoding = enc;
                        debug_printf("Using hextile encoding for client %s\n",
                               cl->host);
                    }
                    break;
                case rfbEncodingZlib:

                    debug_printf("client %s supported rfbEncodingZlib\n",cl->host);
                    if (cl->preferredEncoding == -1) {
                        cl->preferredEncoding = enc;
                        debug_printf("Using zlib encoding for client %s\n",
                                cl->host);
                    }
                  break;
                case rfbEncodingTight:
                    debug_printf("client %s supported rfbEncodingHextile\n",cl->host);

                    if (cl->preferredEncoding == -1) {
                        cl->preferredEncoding = enc;
                        debug_printf("Using tight encoding for client %s\n",
                   cl->host);
                    }
                    break;
                case rfbEncodingXCursor:
                    debug_printf("Enabling X-style cursor updates for client %s\n",
                   cl->host);
                    cl->enableCursorShapeUpdates = TRUE;
                    cl->useRichCursorEncoding = FALSE;
                    cl->cursorWasChanged = TRUE;
                    break;
                case rfbEncodingRichCursor:
                    if (!cl->enableCursorShapeUpdates) {
                        debug_printf("Enabling full-color cursor updates for client "
                    "%s\n", cl->host);
                        cl->enableCursorShapeUpdates = TRUE;
                        cl->useRichCursorEncoding = TRUE;
                        cl->cursorWasChanged = TRUE;
                    }
                    break;
                case rfbEncodingLastRect:
                    debug_printf("client %s supported rfbEncodingLastRect\n",cl->host);
                    if (!cl->enableLastRectEncoding) {
                        debug_printf("Enabling LastRect protocol extension for client "
                   "%s\n", cl->host);
                        cl->enableLastRectEncoding = TRUE;
                    }
                    break;
                default:
                    if ( enc >= (u32)rfbEncodingCompressLevel0 &&
                            enc <= (u32)rfbEncodingCompressLevel9 ) {
                        cl->zlibCompressLevel = enc & 0x0F;
                        cl->tightCompressLevel = enc & 0x0F;
                        debug_printf("Using compression level %d for client %s\n",
                                cl->tightCompressLevel, cl->host);
                    } else if ( enc >= (u32)rfbEncodingQualityLevel0 &&
                    enc <= (u32)rfbEncodingQualityLevel9 ) {
                        cl->tightQualityLevel = enc & 0x0F;
                        debug_printf("Using image quality level %d for client %s\n",
                   cl->tightQualityLevel, cl->host);
                    } else
                        debug_printf("rfbProcessClientNormalMessage: ignoring unknown "
                           "encoding type %d\n", (int)enc);
                    }
                }

                if (cl->preferredEncoding == -1) {
                cl->preferredEncoding = rfbEncodingRaw;
                }

            return;
        }


        case rfbFramebufferUpdateRequest:
        {
            //debug_printf("rfbSetEncodings!\n");
            if ((n = ReadExact(cl, ((char *)&msg) + 1,
                    sz_rfbFramebufferUpdateRequestMsg-1)) <= 0) {
              if (n != 0)
                  debug_printf("rfbProcessClientNormalMessage: read");
              rfbCloseClient(cl);
            return;
            }
            if(msg.fur.incremental==FALSE)//客户端请求整幅数据,出现了某些数据的丢失
            {
                cl->InitDone=FALSE;
                cl->modifiedregion.x=Swap16IfLE(msg.fur.x);
                cl->modifiedregion.y=Swap16IfLE(msg.fur.y);
                cl->modifiedregion.w=Swap16IfLE(msg.fur.w);
                cl->modifiedregion.h=Swap16IfLE(msg.fur.h);
            }
            else
            {
               cl->InitDone=TRUE;
            }

            if (!cl->readyForSetColourMapEntries) {
                /* client hasn't sent a SetPixelFormat so is using server's */
                cl->readyForSetColourMapEntries = TRUE;
                if (!cl->format.trueColour) {
                if (!rfbSendSetColourMapEntries(cl, 0, 256)) {
                //    sraRgnDestroy(tmpRegion);
                //    TSIGNAL(cl->updateCond);
                //    UNLOCK(cl->updateMutex);
                    debug_printf("failed to send the color map!");
                    return;
                }
                }
            }
            cl->HasRequest = 1;
            return;
        }

        case rfbKeyEvent:
            debug_printf("rfbKeyEvent!\n");
            cl->rfbKeyEventsRcvd++;

            if ((n = ReadExact(cl, ((char *)&msg) + 1,
                               sz_rfbKeyEventMsg - 1)) <= 0) {
                if (n != 0)
                    debug_printf("rfbProcessClientNormalMessage: read");
                rfbCloseClient(cl);
                return;
            }
            //打印接受到的键盘值
            msg.ke.key=Swap32IfLE(msg.ke.key);
#if CN_CFG_KEYBOARD == 1
            vncclient_keyevent(cl->screen, msg);
#endif
            return;


        case rfbPointerEvent:
            cl->rfbPointerEventsRcvd++;
            if ((n = ReadExact(cl, ((char *)&msg) + 1,
                               sz_rfbPointerEventMsg - 1)) <= 0)
            {
                if (n != 0)//等于0应该是客户端主动关闭了
                    debug_printf("rfbProcessClientNormalMessage: read");
                rfbCloseClient(cl);
                return;
            }
            //输入touch message
            msg.pe.x = Swap16IfLE(msg.pe.x);
            msg.pe.y = Swap16IfLE(msg.pe.y);

//          debug_printf("rfbPointerEvent!----x=%d y=%d\n", msg.pe.x,msg.pe.y);
#if CN_CFG_KEYBOARD == 1
            vncclient_pointevent(cl->screen, msg);
#endif
            return;

        case rfbClientCutText:
             debug_printf("rfbClientCutText!\n");

            if ((n = ReadExact(cl, ((char *)&msg) + 1,
                               sz_rfbClientCutTextMsg - 1)) <= 0) {
                if (n != 0)
                    debug_printf("rfbProcessClientNormalMessage: read");
                rfbCloseClient(cl);
                return;
            }

            msg.cct.length = Swap32IfLE(msg.cct.length);

            str = (char *)M_MallocLc(msg.cct.length+1, 0);

          if ((n = ReadExact(cl, str, msg.cct.length)) <= 0) {
                if (n != 0)
                   debug_printf("rfbProcessClientNormalMessage: read");
                free(str);
               rfbCloseClient(cl);
               return;
           }
    //        cl->screen->setXCutText(str, msg.cct.length, cl);
            str[msg.cct.length]= 0;
            debug_printf(" the cut messaged=%s\n",str);
            free(str);
            return;
        default:
            debug_printf("rfbProcessClientNormalMessage: unknown message type %d\n",
                    msg.type);
            debug_printf(" ... closing connection\n");
            rfbCloseClient(cl);
            return;
        }
}
Beispiel #3
0
//----从掉电恢复块恢复数据-----------------------------------------------------
//功能: 从掉电恢复块恢复数据,如果掉电恢复块里有有效数据,比较其与目标块的数据是
//      否一致,如果不一致则用掉电恢复块的数据覆盖目标块。无论是否需要恢复,最后
//      均擦除掉电恢复块。
//参数: PCRB_block,掉电恢复块块号,芯片的绝对块号
//      restored,本指针返回被恢复的目标块
//返回: true = 无需恢复或者正确恢复,false = 发生错误,一般是因为目标块是坏块。
//-----------------------------------------------------------------------------
bool_t restore_PCRB_nand(u32 PCRB_block,u32 *restored)
{
    u32 verify;
    u32 address;
    u32 loop;
    u32 protected_block;
    u32 sector_from,sector_to;
    u8 *sector_buf;   //扇区缓冲区,动态分配,不在栈中分配
    bool_t result = true;

    if(PCRB_block >= tg_samsung_nand.block_sum)
        return false;
    //第一页的最后4字节保存受保护的目标块号。
    address =tg_samsung_nand.block_size*PCRB_block + 12;
    ce_active();                        //激活片选
    __write_command_nand(cn_nand_select_oob);    //操作oob页
    __write_address_nand(address);
    __wait_ready_nand( );  //等待芯片内部操作完成

    //受保护的目标块号写入flash,注意:没有做ECC校验,以后补上---db
    protected_block = *pg_nand_data;
    protected_block += (u32)(*pg_nand_data)<<8;
    protected_block += (u32)(*pg_nand_data)<<16;
    protected_block += (u32)(*pg_nand_data)<<24;
    *restored = protected_block;

    ce_inactive();
    if(protected_block > tg_samsung_nand.block_sum)
    {
        erase_block_nand(PCRB_block);
        return true;
    }
    sector_buf = M_MallocLc(u32g_sector_size,0);
    if(sector_buf == NULL)
        return false;
    erase_block_nand(protected_block);
    sector_from = PCRB_block * u32g_sectors_per_block;
    sector_to = protected_block * u32g_sectors_per_block;
    for(loop = 0; loop < u32g_sectors_per_block; loop++)
    {
        verify = __read_sector_nand_with_ecc(
                        sector_from,0,sector_buf,u32g_sector_size);
        if((verify != cn_all_right_verify) && (verify != cn_ecc_right_verify))
        {
            result = false;
            break;
        }
        verify = __write_sector_nand_with_ecc(
                                    sector_to,0,sector_buf,u32g_sector_size);
        if((verify != cn_all_right_verify) && (verify != cn_ecc_right_verify))
        {
            result = false;
            break;
        }
        sector_from++;
        sector_to++;
    }
    free(sector_buf);
    erase_block_nand(PCRB_block);
    return result;
}
Beispiel #4
0
//----扫描可视域---------------------------------------------------------------
//功能: 1、把visible_clip备份到visible_bak中。
//      2、所有窗口生成新的visible_clip
//参数: display,被扫描的显示器
//返回: false=失败,一般是因为剪切域池容量不够
//-----------------------------------------------------------------------------
bool_t __GK_ScanNewVisibleClip(struct tagDisplayRsc *display)
{
    struct tagGkWinRsc *tempwin;
    struct tagRectangle *rect;
    struct tagClipRect *clip,*clip1,*clip_head = NULL;
    s32 num,rect_left,rect_top,rect_right,rect_bottom,loop,temp;
    u8 *sort_array_x,*sort_array_y;

    num = (display->width+1)*sizeof(u8) + (display->height+1)*sizeof(u8);
    sort_array_x = M_MallocLc(num,0);
    if(sort_array_x == NULL)
        return false;
    sort_array_y = sort_array_x + display->width+1;
    memset(sort_array_x,0,num);
    tempwin = display->z_topmost;
//    rect_left = 0;
//    rect_top = 0;
    while(1)
    {     //取窗口可视边框,该边框是窗口受祖先窗口限制后的矩形
        temp = tempwin->limit_left-tempwin->left + tempwin->absx0;
        if(sort_array_x[temp] == 0)
        {
            sort_array_x[temp] = 1;
//            rect_left++;
        }

        temp = tempwin->limit_right-tempwin->left+tempwin->absx0;
        if(sort_array_x[temp] == 0)
        {
            sort_array_x[temp] = 1;
//            rect_left++;
        }

        temp = tempwin->limit_top-tempwin->top + tempwin->absy0;
        if(sort_array_y[temp] == 0)
        {
            sort_array_y[temp] = 1;
//            rect_top++;
        }

        temp = tempwin->limit_bottom-tempwin->top+tempwin->absy0;
        if(sort_array_y[temp] == 0)
        {
            sort_array_y[temp] = 1;
//            rect_top++;
        }

        //执行__GK_GetRedrawClipAll函数注释中的step1
        //保存窗口原来的可视域
        tempwin->visible_bak = tempwin->visible_clip;
        tempwin->visible_clip = NULL;
        if(tempwin != display->desktop)
            tempwin = tempwin->z_back;
        else
            break;
    }
    //处理桌面下的窗口,这些窗口肯定没有可视域
    while(1)
    {
        tempwin = tempwin->z_back;
        if(tempwin == display->z_topmost)
            break;
        tempwin->visible_bak = tempwin->visible_clip;
        tempwin->visible_clip = NULL;
    }
    //按从左到右,从上到下的顺序(顺序不能改变)把所有垂直线、水平线围成的小clip
    //串成双向链表,由clip_head做链表头
    rect_top = 0;
    temp = 0;
    for(rect_bottom =1;rect_bottom <= display->height; rect_bottom++)
    {
        if(sort_array_y[rect_bottom] == 0)
            continue;
        rect_left = 0;
        for(rect_right =1;rect_right <= display->width; rect_right++)
        {
            if(sort_array_x[rect_right] == 0)
                continue;
            clip = (struct tagClipRect*)Mb_Malloc(g_ptClipRectPool,0);
            if(clip != NULL)
            {
                clip->rect.left = rect_left;
                clip->rect.right = rect_right;
                clip->rect.top = rect_top;
                clip->rect.bottom = rect_bottom;
                rect_left = rect_right;
                __GK_ClipConnect(&clip_head,clip);      //把小clip加入到链接起来
                temp++;
            }
            else
            {
                __GK_FreeClipQueue(clip_head);
                free(sort_array_x);
                return false;           //内存池不足,无法生成可视域队列
            }
        }
        rect_top = rect_bottom;
    }
    free(sort_array_x);

    //下面判断小clip的归属,并把他们加入到所属win的new_clip队列中
    tempwin = display->z_topmost;
    while(1)
    {
        clip = clip_head;
        for(loop = temp; loop >0; loop--)
        {
            rect = &(clip->rect);
            if((rect->left>=tempwin->limit_left-tempwin->left+tempwin->absx0)
               &&(rect->top>=tempwin->limit_top-tempwin->top+tempwin->absy0)
               &&(rect->right<=tempwin->limit_right-tempwin->left+tempwin->absx0)
               &&(rect->bottom<=tempwin->limit_bottom-tempwin->top+tempwin->absy0))
            {   //矩形在tempwin的可显示范围内,若不在则无需处理
                //允许alpha或透明,区域将加入窗口可视域,但不从临时链表中删除。
                if(tempwin->dest_blend)
                {
                    clip1 = (struct tagClipRect*)Mb_Malloc(g_ptClipRectPool,0);
                    if(clip1 != NULL)
                    {
                        *clip1 = *clip;
                    }
                    else
                    {
                        __GK_FreeClipQueue(clip_head);
                        return false;           //内存池不足,无法生成可视域队列
                    }
                }else   //不允许透明和alpha,区域加入窗口可视域,从临时链表删除
                {
                    if(clip == clip_head)
                        clip_head = clip_head->next;
                    clip1 = clip;
                    clip->previous->next = clip->next;
                    clip->next->previous = clip->previous;
                    temp--;
                }
                clip = clip->next;
                //把小clip加入到visible_clip队列中
                __GK_ClipConnect(&tempwin->visible_clip,clip1);
            }else       //矩形不在tpwin的可显示范围内,无需处理。
            {
                clip = clip->next;
            }
        }
        __GK_CombineClip_s(tempwin->visible_clip);//合并clip,按先x后y的顺序合并
        if(tempwin != display->desktop)
            tempwin = tempwin->z_back;
        else
            break;
    }
    return true;
}
Beispiel #5
0
bool_t install_vncserver_mirrordisplay(rfbScreenInfoPtr rfbserver)
{
    bool_t  ret=false;
    struct tagDisplayRsc *base_display;
    struct tagGkWinRsc *desktop;
    struct tagDisplayRsc *mirror_display;//我们的镜像显示器

    if(NULL==rfbserver)
    {
        return ret;
    }

    //通过桌面找到显示器,这种方法有点out ---TODO
    desktop = GK_ApiGetDesktop("sim_display");

    if(NULL==desktop)//找不到桌面。
    {
        return ret;
    }
    base_display=desktop->disp;
    if(NULL==base_display)//找不到主显示器
    {
        return ret;
    }
    if((base_display->pixel_format>>8)<8)//暂时不支持8位像素格式
    {
        return ret;
    }
    vncclip_pool = Mb_CreatePool((void*)s_vncclip_rsc,
                                     cn_limit_vncclip,
                                     sizeof(struct tagClipRect),
                                     20,100,
                                     "vncclip_pool");
    if(NULL == vncclip_pool)
    {
        debug_printf("#fatalerror--create the vncclip_pool failed!\n");
        return ret;
    }

    mirror_display=M_MallocLc(sizeof(struct tagDisplayRsc),0);
    if(NULL==mirror_display)
    {
        debug_printf("#fatalerror--malloc mirror display mem failed!\n");
        Mb_DeletePool(vncclip_pool);
        return ret;
    }
    memset(mirror_display,0,sizeof(struct tagDisplayRsc));
    //初始化镜像显示器的一些必备属性,跟主显示器保持一致--TODO,

    mirror_display->pixel_format = base_display->pixel_format;
    mirror_display->width = base_display->width;
    if(cn_vnc_keyboard_visual_enable)
    {
        mirror_display->height = base_display->height + cn_vnc_keyboard_height;
    }
    else
    {
        mirror_display->height = base_display->height;
    }
    mirror_display->frame_buffer = NULL;
    mirror_display->draw.bm_to_screen=vnc_bm_to_screen;

    ret= GK_InstallDisplayMirror(base_display,mirror_display,"vnc_server_disp");

    if(ret)//安装成功
    {   //区域设置
        rfbserver->width=mirror_display->width;
        rfbserver->height=mirror_display->height;
        rfbserver->rfbServerFormat.bitsPerPixel=(mirror_display->pixel_format>>8);
        rfbserver->frameBuffer=M_MallocLc(rfbserver->width*\
                    (rfbserver->height)*(rfbserver->rfbServerFormat.bitsPerPixel/8),0);

        if(NULL==rfbserver->frameBuffer)
        {
            Rsc_DelNode((struct tagRscNode *)mirror_display);
            free(mirror_display);
            Mb_DeletePool(vncclip_pool);
            debug_printf("#fatalerror--malloc rfbserver frame buf failed!\n");

            return ret;
        }
//镜像显示器和其基础显示器公用一个buf。
        //初始化一些rfbserver的参数
        debug_printf("fram buf = %08x   %d bytes\n",rfbserver->frameBuffer,\
           rfbserver->width*(rfbserver->height)*(rfbserver->rfbServerFormat.bitsPerPixel/8));
        memset(rfbserver->frameBuffer,0,rfbserver->width*(rfbserver->height)*(rfbserver->rfbServerFormat.bitsPerPixel/8));
        rfbserver->clip_head=NULL;

        //像素格式
     //   rfbserver->rfbServerFormat.bitsPerPixel=rfbserver->bitsPerPixel;
        //感觉rfbScreen对于色彩的设置有点冗余,可以考虑只用format就好了,后续修正--TODO
        rfbserver->rfbServerFormat.bigEndian=false;
        rfbserver->rfbServerFormat.trueColour=true;
        rfbserver->paddedWidthInBytes=(rfbserver->rfbServerFormat.bitsPerPixel/8)*rfbserver->width;
        switch(rfbserver->rfbServerFormat.bitsPerPixel)//目前就列举这几种吧,后续的再行补充
        {
            case 8://332格式
                debug_printf("the server vmirror_display used 332 format!\n");
                rfbserver->rfbServerFormat.redShift=5;
                rfbserver->rfbServerFormat.greenShift=2;
                rfbserver->rfbServerFormat.blueShift=0;
                rfbserver->rfbServerFormat.redMax=((1<<3)-1);
                rfbserver->rfbServerFormat.greenMax=((1<<3)-1);
                rfbserver->rfbServerFormat.blueMax=((1<<2)-1);
                rfbserver->rfbServerFormat.depth=8;
                break;
            case 16://565格式
                debug_printf("the server vmirror_display used 565 format!\n");
                rfbserver->rfbServerFormat.redShift=11;
                rfbserver->rfbServerFormat.greenShift=5;
                rfbserver->rfbServerFormat.blueShift=0;
                rfbserver->rfbServerFormat.redMax=((1<<5)-1);
                rfbserver->rfbServerFormat.greenMax=((1<<6)-1);
                rfbserver->rfbServerFormat.blueMax=((1<<5)-1);
                rfbserver->rfbServerFormat.depth=16;
                break;
            case 32://真彩色888
                debug_printf("the server vmirror_display used 888 format!\n");
                rfbserver->rfbServerFormat.redShift=16;
                rfbserver->rfbServerFormat.greenShift=8;
                rfbserver->rfbServerFormat.blueShift=0;
                rfbserver->rfbServerFormat.redMax=((1<<8)-1);
                rfbserver->rfbServerFormat.greenMax=((1<<8)-1);
                rfbserver->rfbServerFormat.blueMax=((1<<8)-1);
                rfbserver->rfbServerFormat.depth=24;
                break;
            default://不应该处理,后果很严重,后虚修补bug--TODO
                break;
        }

        vncscreen=rfbserver;
        vnc_set_vncclip_pool(vncclip_pool);
        rfbserver->mirror_display = mirror_display;
        return ret;
    }
    else
    {