Exemplo n.º 1
0
void FileManager :: loadHeader(const char * name_of_file){
    const char* extBin = ".bin";
    std::string result = std::string(directory) +std::string(name_of_file) + std::string(extBin);
    const char * FileNameBin = result.c_str();
    fstream fsr(FileNameBin, std::ios::out | std::ios::in | std::ios::binary );
    if(fsr){
        int temp = fsr.tellg();
        fsr.seekg(0,ios::beg);
        fsr.read((char*)header_buffer, sizeOfHeader);

        nameOfFile = (char*)(header_buffer) ;
        sizeOfFile =(int*)(header_buffer+ TABLESIZE);
        numberOfRegisters = (int*)(header_buffer+34);
        numberOfFreeRegisters = (int*)(header_buffer+38);
        ptrOfFirstRegister = (int*)(header_buffer+42);
        ptrToLastRegister = (int*)(header_buffer+46);
        ptrToFirstRegisterFree = (int*)(header_buffer+50);
        sizeOfRegister = (int*)(header_buffer+54);
        numberOfColumns = (int*)(header_buffer+58);


        fsr.seekg(temp,ios::beg);
    }
    else{
        cout<<"Error 001 : El archivo seleccionado no existe"<<endl;    }

   fsr.close();
}
Exemplo n.º 2
0
void FileManager :: generate_binaryFile(){
    const char* extBin = ".bin";
    std::string result = std::string(directory) +std::string(nameOfFile) + std::string(extBin);
    const char * FileNameBin = result.c_str();
    fstream fsr(FileNameBin, std::ios::out | std::ios::in | std::ios::binary );
    if(fsr){
        ofstream fe(FileNameBin); //Creamos un archivo bin nuevo para una tabla nueva si no existe
        fe.close();
        cout<<"Se creo nuevo archivo binario"<<endl;
    }
    fsr.close();
}
/*
 * Reposition the device to file, block
 *
 * Returns: false on failure
 *          true  on success
 */
bool generic_tape_device::reposition(DCR *dcr, uint32_t rfile, uint32_t rblock)
{
   Dmsg4(100, "reposition from %u:%u to %u:%u\n", file, block_num, rfile, rblock);
   if (rfile < file) {
      Dmsg0(100, "Rewind\n");
      if (!rewind(NULL)) {
         return false;
      }
   }

   if (rfile > file) {
      Dmsg1(100, "fsf %d\n", rfile-file);
      if (!fsf(rfile-file)) {
         Dmsg1(100, "fsf failed! ERR=%s\n", bstrerror());
         return false;
      }
      Dmsg2(100, "wanted_file=%d at_file=%d\n", rfile, file);
   }

   if (rblock < block_num) {
      Dmsg2(100, "wanted_blk=%d at_blk=%d\n", rblock, block_num);
      Dmsg0(100, "bsf 1\n");
      bsf(1);
      Dmsg0(100, "fsf 1\n");
      fsf(1);
      Dmsg2(100, "wanted_blk=%d at_blk=%d\n", rblock, block_num);
   }

   if (has_cap(CAP_POSITIONBLOCKS) && rblock > block_num) {
      /*
       * Ignore errors as Bareos can read to the correct block.
       */
      Dmsg1(100, "fsr %d\n", rblock-block_num);
      return fsr(rblock-block_num);
   } else {
      while (rblock > block_num) {
         if (!dcr->read_block_from_dev(NO_BLOCK_NUMBER_CHECK)) {
            berrno be;
            dev_errno = errno;
            Dmsg2(30, "Failed to find requested block on %s: ERR=%s", prt_name, be.bstrerror());
            return false;
         }
         Dmsg2(300, "moving forward wanted_blk=%d at_blk=%d\n", rblock, block_num);
      }
   }

   return true;
}
Exemplo n.º 4
0
Arquivo: vtape.c Projeto: AlD/bareos
/*
 * Go to next FM
 */
int vtape::fsf()
{
   ASSERT(online);
   ASSERT(current_file >= 0);
   ASSERT(fd >= 0);
/*
 * 1 0 -> fsf -> 2 0 -> fsf -> 2 -1
 */

   int ret=0;
   if (atEOT || atEOD) {
      errno = EIO;
      current_block = -1;
      return -1;
   }

   atBOT = false;
   Dmsg2(dbglevel+1, "fsf %i <= %i\n", current_file, last_file);

   if (next_FM > cur_FM) {      /* not the last file */
      lseek(fd, next_FM, SEEK_SET);
      read_fm(VT_READ_EOF);
      current_file++;
      atEOF = true;
      ret = 0;

   } else if (atEOF) {          /* last file mark */
      current_block=-1;
      errno = EIO;
      atEOF = false;
      atEOD = true;

   } else {                     /* last file, but no at the end */
      fsr(100000);

      Dmsg0(dbglevel, "Try to FSF after EOT\n");
      errno = EIO;
      current_file = last_file ;
      current_block = -1;
      atEOD=true;
      ret = -1;
   }
   return ret;
}
Exemplo n.º 5
0
void FileManager :: openFile(){
    fileBuffer = (char*)calloc(1,getSizeOfFile()-sizeOfHeader);

    const char* extBin = ".bin";
    std::string result = std::string(directory) +std::string(getNameOfFile()) + std::string(extBin);
    const char * FileNameBin = result.c_str();
    fstream fsr(FileNameBin, std::ios::out | std::ios::in | std::ios::binary );
    if(fsr){
        int temp = fsr.tellg();
        fsr.seekg(sizeOfHeader,ios::beg);
        fsr.read((char*)fileBuffer,getSizeOfFile()-sizeOfHeader );

        fsr.seekg(temp,ios::beg);
    }
    else{
        cout<<"no hay archivo"<<endl;    }

   fsr.close();
}
Exemplo n.º 6
0
//框架消息处理函数
bool CServerGameDesk::HandleFrameMessage(BYTE bDeskStation, NetMessageHead * pNetHead, void * pData, UINT uSize, UINT uSocketID, bool bWatchUser)
{
	DebugPrintf("接收到框架消息 位置=【%d】 ID=【%d】",bDeskStation,pNetHead->bAssistantID);

	switch(pNetHead->bAssistantID)
	{
	case ASS_GM_FORCE_QUIT:		//强行退出//安全退出
		{
			char cKey[10];
			CString sPath=CBcfFile::GetAppPath();
			int iResult = 1;
			if (CBcfFile::IsFileExist(sPath + "SpecialRule.bcf"))
			{
				CBcfFile fsr( sPath + "SpecialRule.bcf");
				sprintf(cKey, "%d", NAME_ID);
				iResult = fsr.GetKeyVal (_T("ForceQuitAsAuto"), cKey, 0);
			}

			if(iResult == 0)
			{
				UserQuitStruct s_UserQuit;
				s_UserQuit.bDeskStation = bDeskStation;
				for(int i = 0; i < PLAY_COUNT; ++i)
				{
					if(i != bDeskStation);
					{
						SendGameData(i,&s_UserQuit,sizeof(UserQuitStruct),MDM_GM_GAME_NOTIFY,ASS_USER_QUIT_GAME,0);
					}
				}
				SendWatchData(m_bMaxPeople,&s_UserQuit,sizeof(UserQuitStruct),MDM_GM_GAME_NOTIFY,ASS_USER_QUIT_GAME,0);

				return __super::HandleFrameMessage( bDeskStation,  pNetHead,  pData,  uSize,  uSocketID,  bWatchUser); 
			}

			return true;
		}
	}
	return __super::HandleFrameMessage( bDeskStation,  pNetHead,  pData,  uSize,  uSocketID,  bWatchUser);
}
Exemplo n.º 7
0
Arquivo: vtape.c Projeto: AlD/bareos
int vtape::tape_op(struct mtop *mt_com)
{
   int result=0;
   int count = mt_com->mt_count;

   if (!online) {
      errno = ENOMEDIUM;
      return -1;
   }

   switch (mt_com->mt_op)
   {
   case MTRESET:
   case MTNOP:
   case MTSETDRVBUFFER:
      break;

   default:
   case MTRAS1:
   case MTRAS2:
   case MTRAS3:
   case MTSETDENSITY:
      errno = ENOTTY;
      result = -1;
      break;

   case MTFSF:                  /* Forward space over mt_count filemarks. */
      do {
         result = fsf();
      } while (--count > 0 && result == 0);
      break;

   case MTBSF:                  /* Backward space over mt_count filemarks. */
      do {
         result = bsf();
      } while (--count > 0 && result == 0);
      break;

   case MTFSR:      /* Forward space over mt_count records (tape blocks). */
/*
    file number = 1
    block number = 0

    file number = 1
    block number = 1

    mt: /dev/lto2: Erreur d'entree/sortie

    file number = 2
    block number = 0
*/
      /* tester si on se trouve a la fin du fichier */
      result = fsr(mt_com->mt_count);
      break;

   case MTBSR:      /* Backward space over mt_count records (tape blocks). */
      result = bsr(mt_com->mt_count);
      break;

   case MTWEOF:                 /* Write mt_count filemarks. */
      do {
         result = weof();
      } while (result == 0 && --count > 0);
      break;

   case MTREW:                  /* Rewind. */
      Dmsg0(dbglevel, "rewind vtape\n");
      check_eof();
      atEOF = atEOD = false;
      atBOT = true;
      current_file = 0;
      current_block = 0;
      lseek(fd, 0, SEEK_SET);
      result = !read_fm(VT_READ_EOF);
      break;

   case MTOFFL:                 /* put tape offline */
      result = offline();
      break;

   case MTRETEN:                /* Re-tension tape. */
      result = 0;
      break;

   case MTBSFM:                 /* not used by bareos */
      errno = EIO;
      result = -1;
      break;

   case MTFSFM:                 /* not used by bareos */
      errno = EIO;
      result = -1;
      break;

   case MTEOM:/* Go to the end of the recorded media (for appending files). */
      while (next_FM) {
         lseek(fd, next_FM, SEEK_SET);
         if (read_fm(VT_READ_EOF)) {
            current_file++;
         }
      }
      boffset_t l;
      while (::read(fd, &l, sizeof(l)) > 0) {
         if (l) {
            lseek(fd, l, SEEK_CUR);
         } else {
            ASSERT(0);
         }
         Dmsg0(dbglevel, "skip 1 block\n");
      }
      current_block = -1;
      atEOF = false;
      atEOD = true;

/*
   file number = 3
   block number = -1
*/
      /* Can be at EOM */
      break;

   case MTERASE:                /* not used by bareos */
      atEOD = true;
      atEOF = false;
      atEOT = false;

      current_file = 0;
      current_block = -1;
      lseek(fd, 0, SEEK_SET);
      read_fm(VT_READ_EOF);
      truncate_file();
      break;

   case MTSETBLK:
      break;

   case MTSEEK:
      break;

   case MTTELL:
      break;

   case MTFSS:
      break;

   case MTBSS:
      break;

   case MTWSM:
      break;

   case MTLOCK:
      break;

   case MTUNLOCK:
      break;

   case MTLOAD:
      break;

   case MTUNLOAD:
      break;

   case MTCOMPRESSION:
      break;

   case MTSETPART:
      break;

   case MTMKPART:
      break;
   }

   return result == 0 ? 0 : -1;
}
Exemplo n.º 8
0
Arquivo: vtape.c Projeto: AlD/bareos
/*
 * BSR + EOF => begin of EOF + EIO
 * BSR + BSR + EOF => last block
 * current_block = -1
 */
int vtape::bsr(int count)
{
   ASSERT(online);
   ASSERT(current_file >= 0);
   ASSERT(count == 1);
   ASSERT(fd >= 0);

   check_eof();

   if (!count) {
      return 0;
   }

   int ret=0;
   int last_f=0;
   int last_b=0;

   boffset_t last=-1, last2=-1;
   boffset_t orig = lseek(fd, 0, SEEK_CUR);
   int orig_f = current_file;
   int orig_b = current_block;

   Dmsg4(dbglevel, "bsr(%i) cur_blk=%i orig=%lli cur_FM=%lli\n",
         count, current_block, orig, cur_FM);

   /* begin of tape, do nothing */
   if (atBOT) {
      errno = EIO;
      return -1;
   }

   /* at EOF 0:-1 BOT=0 EOD=0 EOF=0 ERR: Input/output error  */
   if (atEOF) {
      lseek(fd, cur_FM, SEEK_SET);
      atEOF = false;
      if (current_file > 0) {
         current_file--;
      }
      current_block=-1;
      errno = EIO;
      return -1;
   }

   /*
    * First, go to cur/last_FM and read all blocks to find the good one
    */
   if (cur_FM == orig) {        /* already just before  EOF */
      lseek(fd, last_FM, SEEK_SET);

   } else {
      lseek(fd, cur_FM, SEEK_SET);
   }

   ret = read_fm(VT_READ_EOF);

   do {
      if (!atEOF) {
         last2 = last;          /* keep track of the 2 last blocs position */
         last = lseek(fd, 0, SEEK_CUR);
         last_f = current_file;
         last_b = current_block;
         Dmsg6(dbglevel, "EOF=%i last2=%lli last=%lli < orig=%lli %i:%i\n",
               atEOF, last2, last, orig, current_file, current_block);
      }
      ret = fsr(1);
   } while ((lseek(fd, 0, SEEK_CUR) < orig) && (ret == 0));

   if (last2 > 0 && atEOF) {    /* we take the previous position */
      lseek(fd, last2, SEEK_SET);
      current_file = last_f;
      current_block = last_b - 1;
      Dmsg3(dbglevel, "1 set offset2=%lli %i:%i\n",
            last, current_file, current_block);

   } else if (last > 0) {
      lseek(fd, last, SEEK_SET);
      current_file = last_f;
      current_block = last_b;
      Dmsg3(dbglevel, "2 set offset=%lli %i:%i\n",
            last, current_file, current_block);
   } else {
      lseek(fd, orig, SEEK_SET);
      current_file = orig_f;
      current_block = orig_b;
      return -1;
   }

   Dmsg2(dbglevel, "bsr %i:%i\n", current_file, current_block);
   errno=0;
   atEOT = atEOF = atEOD = false;
   atBOT = (lseek(fd, 0, SEEK_CUR) - (sizeof(uint32_t)+2*sizeof(boffset_t))) == 0;

   if (orig_b == -1) {
      current_block = orig_b;
   }

   return 0;
}
Exemplo n.º 9
0
 void fake_system::register_funct( const std::string& name, const fake_system_funct_t& funct )
 {
   fake_sys_rep fsr( name, funct );
   sys_functs.push_back( fsr );
 }
Exemplo n.º 10
0
///desc:获得所有游戏房间信息//W_0002.2
bool CServiceManage::GetRoomListInfo()
{
	////注册码检测////
	//bool bCheck = false;
	//bCheck = CheckLicense();
	//if(!bCheck)
	//{
	//	return false;
	//}

	//AfxMessageBox("GetRoomListInfo!");

	HANDLE hDatabase=sqlAddConnection("BZGameLocal.BCF");
	if(hDatabase<(HANDLE)0x1000)
		return false;
	HANDLE hRecord=sqlSPSetName(hDatabase,"SP_GetRoomList");
	if(hRecord<(HANDLE)0x1000)
		return false;

	try
	{

		sqlSPAddPara(hDatabase,hRecord,"@ServiceName",m_ServiceName,m_ServiceName.GetLength());
		sqlSPExec(hDatabase,hRecord,true);
		while(!sqlEndOfFile(hDatabase,hRecord))
		{
			bool goOn=false,update=false;
			UINT ui=0,uID=0,uPort=0;//无符号
			__int64 i64 = 0;
			//INT ui=0;//符号
			//定义变量
			SC_GameRoomInitStruct * pGameRoomInitInfo=new SC_GameRoomInitStruct;
			memset(pGameRoomInitInfo,0,sizeof(SC_GameRoomInitStruct));

            // PengJiLin, 2011-4-2, 指定哪些游戏是可用的
            sqlGetValue(hDatabase,hRecord,TEXT("NameID"),ui);
			pGameRoomInitInfo->InitInfo.iGameID = ui;
            if(FALSE == m_GameSelecter.GameIsUsable(ui))
            {
                sqlMoveNext(hDatabase,hRecord);
                delete pGameRoomInitInfo;
                continue;
            }

			//已经读取过的不加
			sqlGetValue(hDatabase,hRecord,TEXT("ServerInfoID"),uID);
			sqlGetValue(hDatabase,hRecord,TEXT("SocketPort"),uPort);
			for(int i=0;i<m_ComRoomInfo.GetCount();i++)
			{
				SC_GameRoomInitStruct * p;
				p = (SC_GameRoomInitStruct *)m_ComRoomInfo.GetAt(i);
				//启动的房间
				if(p->uServiceID==uID&&p->InitInfo.uListenPort==uPort&&p->hDllInstance!=NULL&&p->pIManageService!=NULL)
				{

					goOn=true;
					break;
				}
				//停止的房间
				if(p->uServiceID==uID&&p->InitInfo.uListenPort==uPort&&p->hDllInstance==NULL&&p->pIManageService==NULL)
				{
					update=true;
					delete pGameRoomInitInfo;
					pGameRoomInitInfo=p;
					break;
				}
			}
			if(goOn)
			{
				//移动下一条
				sqlMoveNext(hDatabase,hRecord);
				continue;
			}
			if(!update)
				m_ComRoomInfo.Add(pGameRoomInitInfo);
			//读取附加信息
			sqlGetValue(hDatabase,hRecord,TEXT("IDSort"),ui);
			pGameRoomInitInfo->uSortID=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("KindID"),ui);
			pGameRoomInitInfo->uKindID=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("EnableRoom"),pGameRoomInitInfo->bEnable);

			sqlGetValue(hDatabase,hRecord,TEXT("ServerInfoID"),ui);

			pGameRoomInitInfo->uServiceID=ui;////////////////
			//sqlGetValue(hDatabase,hRecord,TEXT("Note"),pGameRoomInitInfo->szRoomNote,sizeof(pGameRoomInitInfo->szRoomNote));
			//读取组件信息
			sqlGetValue(hDatabase,hRecord,TEXT("NameID"),ui);
			pGameRoomInitInfo->ServiceInfo.uNameID=ui;////////////
			sqlGetValue(hDatabase,hRecord,TEXT("DeskPeople"),ui);
			pGameRoomInitInfo->ServiceInfo.uDeskPeople=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("SupportType"),ui);
			pGameRoomInitInfo->ServiceInfo.uSupportType=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("ServiceVer"),ui);
			pGameRoomInitInfo->ServiceInfo.uServiceVer=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("GameName"),pGameRoomInitInfo->ServiceInfo.szGameName,sizeof(pGameRoomInitInfo->ServiceInfo.szGameName));
			sqlGetValue(hDatabase,hRecord,TEXT("GameTable"),pGameRoomInitInfo->ServiceInfo.szGameTable,sizeof(pGameRoomInitInfo->ServiceInfo.szGameTable));
			sqlGetValue(hDatabase,hRecord,TEXT("DLLFileName"),pGameRoomInitInfo->ServiceInfo.szDLLFileName,sizeof(pGameRoomInitInfo->ServiceInfo.szDLLFileName));
			//sqlGetValue(hDatabase,hRecord,TEXT("Writer"),pGameRoomInitInfo->ServiceInfo.szWriter,sizeof(pGameRoomInitInfo->ServiceInfo.szWriter));
			//sqlGetValue(hDatabase,hRecord,TEXT("DllNote"),pGameRoomInitInfo->ServiceInfo.szDllNote,sizeof(pGameRoomInitInfo->ServiceInfo.szDllNote));

			//读取房间信息
			sqlGetValue(hDatabase,hRecord,TEXT("RoomRule"),ui);
			pGameRoomInitInfo->InitInfo.dwRoomRule=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("UserPower"),ui);
			pGameRoomInitInfo->InitInfo.dwUserPower=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("GameTypeID"),ui);
			pGameRoomInitInfo->InitInfo.uComType=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("BasePoint"),ui);
			pGameRoomInitInfo->InitInfo.uBasePoint=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("LessPoint"),ui);
			pGameRoomInitInfo->InitInfo.uLessPoint=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("MaxPoint"),ui);
			pGameRoomInitInfo->InitInfo.uMaxPoint=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("MaxLimite"),ui);
			pGameRoomInitInfo->InitInfo.uMaxLimite=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("RunPublish"),ui);
			pGameRoomInitInfo->InitInfo.uRunPublish=ui;				
			sqlGetValue(hDatabase,hRecord,TEXT("Tax"),ui);
			pGameRoomInitInfo->InitInfo.uTax=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("SocketPort"),ui);
			pGameRoomInitInfo->InitInfo.uListenPort=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("MaxPeople"),ui);
			pGameRoomInitInfo->InitInfo.uMaxPeople=ui;
			pGameRoomInitInfo->InitInfo.iSocketSecretKey = SECRET_KEY;
			/////////////////////////////////////////////////////////
			/////////Kylin 20090116 Vip登陆功能
			sqlGetValue(hDatabase,hRecord,TEXT("VipResever"),ui);
			pGameRoomInitInfo->InitInfo.uVipReseverCount=ui;
			/////////////////////////////////////////////////////////
			//////////////////////////////////////////////////////////////////////////
			//20081211 , Fred Huang  Start
			sqlGetValue(hDatabase,hRecord,TEXT("VirtualUser"),ui);
			pGameRoomInitInfo->InitInfo.uVirtualUser=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("VirtualGameTime"),ui);
			pGameRoomInitInfo->InitInfo.uVirtualGameTime=ui;
			//20081211 , Fred Huang  Stop
			//////////////////////////////////////////////////////////////////////////

			//wushuqun 2009.6.5
			//添加游戏混战场--begin
			sqlGetValue(hDatabase,hRecord,TEXT("BattleRoomID"),ui);
			pGameRoomInitInfo->InitInfo.uBattleRoomID = ui;
			sqlGetValue(hDatabase,hRecord,TEXT("BattleMatchTable"),pGameRoomInitInfo->InitInfo.szBattleGameTable,
				sizeof(pGameRoomInitInfo->InitInfo.szBattleGameTable));
			////////////////--end

			///< 金葫芦二代,是否VIP房间(VIP房间设置密码)
			sqlGetValue(hDatabase,hRecord,TEXT("VIPRoom"),ui);
			pGameRoomInitInfo->InitInfo.bVIPRoom = (ui!=0);

			sqlGetValue(hDatabase,hRecord,TEXT("DeskCount"),ui);
			pGameRoomInitInfo->InitInfo.uDeskCount=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("RoomID"),ui);
			pGameRoomInitInfo->InitInfo.uRoomID=ui;
			sqlGetValue(hDatabase,hRecord,TEXT("StopLogon"),ui);
			pGameRoomInitInfo->InitInfo.uStopLogon=0;
			sqlGetValue(hDatabase,hRecord,TEXT("RoomName"),pGameRoomInitInfo->InitInfo.szGameRoomName,sizeof(pGameRoomInitInfo->InitInfo.szGameRoomName));
			sqlGetValue(hDatabase,hRecord,TEXT("ServerIP"),m_Info.m_szServiceIP,sizeof(m_Info.m_szServiceIP));
			sqlGetValue(hDatabase,hRecord,TEXT("TableLock"),pGameRoomInitInfo->InitInfo.szLockTable,sizeof(pGameRoomInitInfo->InitInfo.szLockTable));
			//wushuqun 2009.6.5
			if (pGameRoomInitInfo->InitInfo.uBattleRoomID > 0)
			{
				memcpy(pGameRoomInitInfo->InitInfo.szGameTable,
					pGameRoomInitInfo->InitInfo.szBattleGameTable,
					sizeof(pGameRoomInitInfo->InitInfo.szBattleGameTable));
			}
			else
			{
				sqlGetValue(hDatabase,hRecord,TEXT("TableMatch"),pGameRoomInitInfo->InitInfo.szGameTable,sizeof(pGameRoomInitInfo->InitInfo.szGameTable));
			}
			////////////////////
			sqlGetValue(hDatabase,hRecord,TEXT("TableIPRule"),pGameRoomInitInfo->InitInfo.szIPRuleTable,sizeof(pGameRoomInitInfo->InitInfo.szIPRuleTable));
			sqlGetValue(hDatabase,hRecord,TEXT("TableUserNameRule"),pGameRoomInitInfo->InitInfo.szNameRuleTable,sizeof(pGameRoomInitInfo->InitInfo.szNameRuleTable));
			//sqlGetValue(hDatabase,hRecord,TEXT("CenterSQLIP"),pGameRoomInitInfo->InitInfo.szSQLIP,sizeof(pGameRoomInitInfo->InitInfo.szSQLIP));
			//sqlGetValue(hDatabase,hRecord,TEXT("LogonSQLIP"),pGameRoomInitInfo->InitInfo.szLogonSQLIP,sizeof(pGameRoomInitInfo->InitInfo.szLogonSQLIP));
			//sqlGetValue(hDatabase,hRecord,TEXT("NativaSQLIP"),pGameRoomInitInfo->InitInfo.szNativeSQLIP,sizeof(pGameRoomInitInfo->InitInfo.szNativeSQLIP));
			// 增加百家乐桌型 add by wlr 20090714

			//{{ Add by lxl 2010-10-08 房间密码
			sqlGetValue(hDatabase,hRecord,TEXT("RoomPassword"),pGameRoomInitInfo->InitInfo.szRoomPassWord,sizeof(pGameRoomInitInfo->InitInfo.szRoomPassWord));
			/// 看是不是百家乐类型的游戏
			char cKey[10];
			CString sPath=CBcfFile::GetAppPath();
			int iResult = 0;
			if (CBcfFile::IsFileExist(sPath + "SpecialRule.bcf"))
			{
				CBcfFile fsr( sPath + "SpecialRule.bcf");
				sprintf(cKey, "%d", pGameRoomInitInfo->ServiceInfo.uNameID);
				iResult = fsr.GetKeyVal (_T("BJLType"), cKey, 0);
			}
			
			if (iResult!=0)
			{
				pGameRoomInitInfo->InitInfo.uDeskType = DESK_TYPE_BJL;
			}
			else
			{
				pGameRoomInitInfo->InitInfo.uDeskType = DESK_TYPE_NORMAL;
			}
			//end of add by wlr 20090714



			//比赛rongqiufen20120106
			if (pGameRoomInitInfo->InitInfo.dwRoomRule & GRR_CONTEST)
			{
				CTime _Now = CTime::GetCurrentTime();
				int nYear = 0, nMonth = 0, nDate = 0, nHour = 0, nMin = 0, nSec = 0, nss = 0;  
				CString temp;
			//	sqlGetValue(hDatabase, hRecord, TEXT("StartTime"), temp);
				if (temp != "")
				{
					sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

					CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
					pGameRoomInitInfo->InitInfo.i64TimeStart = _t.GetTime();
				}
				else
				{
					pGameRoomInitInfo->InitInfo.i64TimeStart = 0;
				}
			//	sqlGetValue(hDatabase, hRecord, TEXT("EndTime"), temp);
				if (temp != "")
				{
					sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

					CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
					pGameRoomInitInfo->InitInfo.i64TimeEnd = _t.GetTime();
				}
				else
				{
					pGameRoomInitInfo->InitInfo.i64TimeEnd = 0;
				}
				
				sqlGetValue(hDatabase,hRecord,TEXT("Chip"), pGameRoomInitInfo->InitInfo.i64Chip);
				sqlGetValue(hDatabase,hRecord,TEXT("LowChip"), pGameRoomInitInfo->InitInfo.i64LowChip);
				sqlGetValue(hDatabase,hRecord,TEXT("LowCount"), ui);
				pGameRoomInitInfo->InitInfo.iLowCount = ui; 
				sqlGetValue(hDatabase,hRecord,TEXT("ContestID"), ui);
				pGameRoomInitInfo->InitInfo.iContestID = ui; 
				sqlGetValue(hDatabase,hRecord,TEXT("Timeout"), ui);
				pGameRoomInitInfo->InitInfo.iTimeout = ui;
				sqlGetValue(hDatabase,hRecord,TEXT("LeastPeople"), ui);
				pGameRoomInitInfo->InitInfo.iLeasePeople = ui;
				sqlGetValue(hDatabase,hRecord,TEXT("UpPeople"), ui);
				pGameRoomInitInfo->InitInfo.iUpPeople = ui;
				pGameRoomInitInfo->InitInfo.uLessPoint = 0;
			}
			//租赁房间ID与时间
			sqlGetValue(hDatabase,hRecord,TEXT("tenancyID"), pGameRoomInitInfo->InitInfo.iLeaseID);
			if (pGameRoomInitInfo->InitInfo.iLeaseID != 0)
			{
				int nYear = 0, nMonth = 0, nDate = 0, nHour = 0, nMin = 0, nSec = 0, nss = 0;  
				CString temp;
				sqlGetValue(hDatabase, hRecord, TEXT("OpenRoomDate"), temp);
				if (temp != "")
				{
					sscanf(temp.GetBuffer(), TEXT("%d-%d-%d %d:%d:%d.%d"), &nYear, &nMonth, &nDate, &nHour, &nMin, &nSec, &nss);

					CTime _t(nYear, nMonth, nDate, nHour, nMin, nSec); 
					pGameRoomInitInfo->InitInfo.i64LeaseTimeStart = _t.GetTime();
				}
				else
				{
					pGameRoomInitInfo->InitInfo.i64LeaseTimeStart = 0;
				}
				int idays = 0;
				sqlGetValue(hDatabase,hRecord,TEXT("AppleyDays"),idays);
				pGameRoomInitInfo->InitInfo.i64LeaseTimeEnd = pGameRoomInitInfo->InitInfo.i64LeaseTimeStart + idays * 24 * 60 * 60;
			}

			//每局时长送金币
			sqlGetValue(hDatabase,hRecord,TEXT("SendTimeLength"), pGameRoomInitInfo->InitInfo.iTimeLength);
			sqlGetValue(hDatabase,hRecord,TEXT("SendCount"), pGameRoomInitInfo->InitInfo.iSendCount);

			sqlMoveNext(hDatabase,hRecord);
		}
		sqlCloseConnection(hDatabase);

		return true;
	}
	catch (...) 
	{ 
		TRACE("CATCH:%s with %s\n",__FILE__,__FUNCTION__);
		if (m_pIMessage!=NULL) 
			m_pIMessage->ShowMessage(TEXT("组件的子实例信息读取发生错误,稍后再次尝试..."));
	}

}
/*
 * Foward space a file
 *
 * Returns: true  on success
 *          false on failure
 */
bool generic_tape_device::fsf(int num)
{
   int32_t os_file = 0;
   struct mtop mt_com;
   int status = 0;

   if (!is_open()) {
      dev_errno = EBADF;
      Mmsg0(errmsg, _("Bad call to fsf. Device not open\n"));
      Emsg0(M_FATAL, 0, errmsg);
      return false;
   }

   if (at_eot()) {
      dev_errno = 0;
      Mmsg1(errmsg, _("Device %s at End of Tape.\n"), prt_name);
      return false;
   }

   if (at_eof()) {
      Dmsg0(200, "ST_EOF set on entry to FSF\n");
   }

   Dmsg0(100, "fsf\n");
   block_num = 0;

   /*
    * If Fast forward space file is set, then we
    * use MTFSF to forward space and MTIOCGET
    * to get the file position. We assume that
    * the SCSI driver will ensure that we do not
    * forward space past the end of the medium.
    */
   if (has_cap(CAP_FSF) && has_cap(CAP_MTIOCGET) && has_cap(CAP_FASTFSF)) {
      int my_errno = 0;
      mt_com.mt_op = MTFSF;
      mt_com.mt_count = num;
      status = d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
      if (status < 0) {
         my_errno = errno;            /* save errno */
      } else if ((os_file=get_os_tape_file()) < 0) {
         my_errno = errno;            /* save errno */
      }
      if (my_errno != 0) {
         berrno be;

         set_eot();
         Dmsg0(200, "Set ST_EOT\n");
         clrerror(mt_com.mt_op);
         Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), prt_name, be.bstrerror(my_errno));
         Dmsg1(200, "%s", errmsg);
         return false;
      }

      Dmsg1(200, "fsf file=%d\n", os_file);
      set_ateof();
      file = os_file;
      return true;

   /*
    * Here if CAP_FSF is set, and virtually all drives
    * these days support it, we read a record, then forward
    * space one file. Using this procedure, which is slow,
    * is the only way we can be sure that we don't read
    * two consecutive EOF marks, which means End of Data.
    */
   } else if (has_cap(CAP_FSF)) {
      POOLMEM *rbuf;
      int rbuf_len;
      Dmsg0(200, "FSF has cap_fsf\n");
      if (max_block_size == 0) {
         rbuf_len = DEFAULT_BLOCK_SIZE;
      } else {
         rbuf_len = max_block_size;
      }
      rbuf = get_memory(rbuf_len);
      mt_com.mt_op = MTFSF;
      mt_com.mt_count = 1;
      while (num-- && !at_eot()) {
         Dmsg0(100, "Doing read before fsf\n");
         if ((status = this->read((char *)rbuf, rbuf_len)) < 0) {
            if (errno == ENOMEM) {     /* tape record exceeds buf len */
               status = rbuf_len;        /* This is OK */
            /*
             * On IBM drives, they return ENOSPC at EOM instead of EOF status
             */
            } else if (at_eof() && errno == ENOSPC) {
               status = 0;
            } else if (has_cap(CAP_IOERRATEOM) && at_eof() && errno == EIO) {
               if (has_cap(CAP_IBMLINTAPE)) {
                  Dmsg0(100, "Got EIO on read, checking lin_tape sense data\n");
                  if (check_scsi_at_eod(m_fd)) {
                     Dmsg0(100, "Sense data confirms it's EOD\n");
                     status = 0;
                  } else {
                     Dmsg0(100, "Not at EOD, might be a real error. Check sense trace from lin_taped logs.\n");
                     set_eot();
                     clrerror(-1);
                     Mmsg1(errmsg, _("read error on %s. ERR=Input/Output error.\n"), prt_name);
                     break;
                  }
               } else {
                  Dmsg0(100, "Got EIO on read, assuming that's due to EOD\n");
                  status = 0;
               }
            } else {
               berrno be;

               set_eot();
               clrerror(-1);
               Dmsg2(100, "Set ST_EOT read errno=%d. ERR=%s\n", dev_errno, be.bstrerror());
               Mmsg2(errmsg, _("read error on %s. ERR=%s.\n"), prt_name, be.bstrerror());
               Dmsg1(100, "%s", errmsg);
               break;
            }
         }
         if (status == 0) {                /* EOF */
            Dmsg1(100, "End of File mark from read. File=%d\n", file+1);
            /*
             * Two reads of zero means end of tape
             */
            if (at_eof()) {
               set_eot();
               Dmsg0(100, "Set ST_EOT\n");
               break;
            } else {
               set_ateof();
               continue;
            }
         } else {                        /* Got data */
            clear_eot();
            clear_eof();
         }

         Dmsg0(100, "Doing MTFSF\n");
         status = d_ioctl(m_fd, MTIOCTOP, (char *)&mt_com);
         if (status < 0) {                 /* error => EOT */
            berrno be;

            set_eot();
            Dmsg0(100, "Set ST_EOT\n");
            clrerror(mt_com.mt_op);
            Mmsg2(errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"), prt_name, be.bstrerror());
            Dmsg0(100, "Got < 0 for MTFSF\n");
            Dmsg1(100, "%s", errmsg);
         } else {
            set_ateof();
         }
      }
      free_memory(rbuf);

   /*
    * No FSF, so use FSR to simulate it
    */
   } else {
      Dmsg0(200, "Doing FSR for FSF\n");
      while (num-- && !at_eot()) {
         fsr(INT32_MAX);    /* returns -1 on EOF or EOT */
      }
      if (at_eot()) {
         dev_errno = 0;
         Mmsg1(errmsg, _("Device %s at End of Tape.\n"), prt_name);
         status = -1;
      } else {
         status = 0;
      }
   }
   Dmsg1(200, "Return %d from FSF\n", status);
   if (at_eof()) {
      Dmsg0(200, "ST_EOF set on exit FSF\n");
   }
   if (at_eot()) {
      Dmsg0(200, "ST_EOT set on exit FSF\n");
   }
   Dmsg1(200, "Return from FSF file=%d\n", file);

   return status == 0;
}