Exemple #1
0
void InitialPermutation(EncryptBlk *sourceBlkPTr,EncryptBlk *resultBlkPTr )
{
	doubleLong 	dataToEncrypt;
	uint32_t 	resultLow = 0;
	uint32_t 	resultHi = 0;
	register uint32_t gTestVal = 0;

#if TARGET_RT_BIG_ENDIAN
	dataToEncrypt.bits49to64 = sourceBlkPTr->keyLo & klowWord;
	dataToEncrypt.bits33to48 = sourceBlkPTr->keyHi & klowWord;
	dataToEncrypt.bits17to32 = sourceBlkPTr->keyLo >> kwordSize;
	dataToEncrypt.bits1to16  = sourceBlkPTr->keyHi >> kwordSize;
#else
	dataToEncrypt.bits49to64 = CFSwapInt16(sourceBlkPTr->keyLo >> kwordSize);
	dataToEncrypt.bits33to48 = CFSwapInt16(sourceBlkPTr->keyHi >> kwordSize);
	dataToEncrypt.bits17to32 = CFSwapInt16(sourceBlkPTr->keyLo & klowWord);
	dataToEncrypt.bits1to16  = CFSwapInt16(sourceBlkPTr->keyHi & klowWord);
#endif
	
	Extract(&dataToEncrypt, &resultLow, &resultHi);

	RORightLong(resultLow)
	RORightLong(resultHi)

	Extract(&dataToEncrypt, &resultLow, &resultHi);
	
	resultBlkPTr->keyLo = resultLow;
	resultBlkPTr->keyHi = resultHi;
}
Bool HandleLookNewsgroup(char *ptr, long len)
{
   ID resource_id;
   WORD newsgroup;
   BYTE permission;
   char message[MAXMESSAGE + 1];
   char* msg = message;
   int temp_len;
   object_node obj;

   temp_len = SIZE_NEWSGROUP_ID + 1 + SIZE_ID * 4 + SIZE_ANIMATE;
   if (len < temp_len)
      return False;

   Extract(&ptr, &newsgroup, SIZE_NEWSGROUP_ID);
   Extract(&ptr, &permission, 1);

   ExtractObject(&ptr, &obj);
   Extract(&ptr, &resource_id, SIZE_ID);

   /* Remove format string id # & other ids from length */
   if (!CheckServerMessage(&msg, &ptr, len - temp_len, resource_id))
      return False;

   UserReadNews(&obj, msg, newsgroup, permission);

   return True;
}
Bool HandleLookupNames(char *ptr, long len)
{
   WORD num_objects;
   int i;
   ID objs[MAX_RECIPIENTS];
   char *start = ptr;

   Extract(&ptr, &num_objects, 2);

   if (num_objects > MAX_RECIPIENTS)
   {
      debug(("Too many recipients %d\n", (int) num_objects));
      return False;
   }
   
   for (i=0; i < num_objects; i++)
      Extract(&ptr, &objs[i], SIZE_ID);
   
   len -= (ptr - start);
   if (len != 0)
   {
      SafeFree(objs);
      return False;
   }

   MailRecipientsReceived(num_objects, objs);
   
   return True;
}
Exemple #4
0
void pasv(srv_config *sCon, srv_config *spCon){
    printf("pasv\n");
    char pasv_data[512];
    char *buff = "PASV\r\n";
    if (send(sCon->sock, buff, strlen(buff), 0) == INVALID_SOCKET) return 0;
    char *recv_datas = recv_data(sCon->sock);
    printf(recv_datas);
    char *ip_tmp = strstr(recv_datas, "(");
    char ip[512];
    int port;
    char port_buffer[512];
    int pos = Extract(ip_tmp, ip, 1, ',');
    int i;
    for (i=0; i!=3; i++)
        if ((pos = Extract(ip_tmp, ip, pos, ',')) ==-1) exit(-1);
    ip[strlen(ip)-1] = '\0';
    CharReplace(ip, ',', '.');
    if ((pos = Extract(ip_tmp, port_buffer, pos, ',')) ==-1) exit(-1);
    port_buffer[strlen(port_buffer)-1] = '\0';
    port = atoi(port_buffer)*256;
    memset(port_buffer, '\0', strlen(port_buffer));
    if ((pos = Extract(ip_tmp, port_buffer, pos, ')')) ==-1) exit(-1);
    port_buffer[strlen(port_buffer)-1] = '\0';
    port = port+atoi(port_buffer);
    spCon->ip = ip;
    spCon->port = port;
    gen_baseinfo(spCon);
    printf("IP: %s Port: %d\n", spCon->ip, spCon->port);
}
Bool HandleMail(char *ptr, long len)
{
   long index;
   WORD num_recipients, i;
   char message[MAXMESSAGE + MAX_SUBJECT + 200];
   char* msg = message;
   char sender[MAXUSERNAME + 1];
   char recipients[MAX_RECIPIENTS][MAXUSERNAME + 1];
   ID resource_id;
   long msg_time;
   char *start = ptr;

   Extract(&ptr, &index, 4);
   len -= 4;
   len = ExtractString(&ptr, len, sender, MAXUSERNAME);
   if (len == -1)
      return False;
   Extract(&ptr, &msg_time, SIZE_TIME);
   Extract(&ptr, &num_recipients, SIZE_NUM_RECIPIENTS);
   len -= SIZE_TIME + SIZE_NUM_RECIPIENTS;

   // If somehow mail message is screwed up, delete it
   if (num_recipients > MAX_RECIPIENTS)
   {
      RequestDeleteMail(index);
      return False;
   }

   /* If no recipients, then there is no more mail */
   if (num_recipients == 0)
   {
      MailNewMessage(0, sender, 0, NULL, NULL, 0);
      return True;
   }

   for (i=0; i < num_recipients; i++)
   {
      len = ExtractString(&ptr, len, recipients[i], MAXUSERNAME);
      if (len == -1)
         return False;
   }
   
   Extract(&ptr, &resource_id, SIZE_ID);
   len -= SIZE_ID;
   
   /* Remove format string id # & other ids from length */
   if (!CheckServerMessage(&msg, &ptr, len, resource_id))
      return False;

   MailNewMessage(index, sender, num_recipients, recipients, msg, msg_time);

   return True;
}
void Controller::OpenInMiniBrowser( UINT i)
{
	if( pArchiveFile->GetStatus() != ArchiveFile::Status::UNCOMPRESSED)
	{
		return ;
	}

	File* pFile = pArchiveFile->GetChildFile( i) ;
	if( !pFile)
	{
		return ;
	}

	// ファイル名取得
	string str = "zipmp3tmp" ;
	char pszTmpPath[ MAX_PATH + 1] ;
	GetTempPath( MAX_PATH, pszTmpPath) ;
	char pszPath[ MAX_PATH + 1] ;
	GetTempFileName( pszTmpPath, str.c_str(), 0, pszPath) ;

	// 解凍
	if(Extract( i, pszPath))
	{
		if( GetFileAttributes( strPrevTmpPath.c_str()) != -1)
		{
			DeleteFile( strPrevTmpPath.c_str()) ;
		}
		strPrevTmpPath = pszPath ;

		// 開く
		SendMessage( pMainWnd->GetWinampWindow(), WM_WA_IPC, (WPARAM)pszPath, IPC_MBOPENREAL) ;
		SendMessage( pMainWnd->GetWinampWindow(), WM_WA_IPC, (WPARAM)NULL, IPC_MBOPENREAL) ;
	}
}
Exemple #7
0
    void GenericBsa::Extract(const std::string& assetPath,
                             const boost::filesystem::path& destRootPath,
                             const bool overwrite) const {
        fs::path outFilePath = destRootPath / assetPath;

        if (!overwrite && fs::exists(outFilePath))
            throw error(LIBBSA_ERROR_FILESYSTEM_ERROR, "The file \"" + outFilePath.string() + "\" already exists.");

        try {
            //Create parent directories.
            fs::create_directories(outFilePath.parent_path());  //This creates any directories in the path that don't already exist.

            const uint8_t * data;
            size_t dataSize;
            Extract(assetPath, &data, &dataSize);

            //Write new file.
            boost::filesystem::ofstream out(outFilePath, ios::binary | ios::trunc);
            out.exceptions(ios::failbit | ios::badbit | ios::eofbit);  //Causes ifstream::failure to be thrown if problem is encountered.

            out.write((char*)data, dataSize);

            out.close();
        }
        catch (ios_base::failure& e) {
            throw error(LIBBSA_ERROR_FILESYSTEM_ERROR, e.what());
        }
    }
Exemple #8
0
 void GenericBsa::Extract(const vector<BsaAsset>& assetsToExtract,
                          const boost::filesystem::path& destRootPath,
                          const bool overwrite) const {
     for (const auto& asset : assetsToExtract) {
         Extract(asset.path, destRootPath, overwrite);
     }
 }
Exemple #9
0
int ArchivePanel::pGetFiles(
		const PluginPanelItem *PanelItem,
		int ItemsNumber,
		int Move,
		const TCHAR* DestPath,
		int OpMode
		)
{
	int bResult = false; ///!!! error!!!

	bool bExtractWithoutPath = true;

#ifdef UNICODE
	DestPath = *(TCHAR**)DestPath;
#endif

	if ( OpMode & (OPM_VIEW | OPM_EDIT | OPM_FIND | OPM_QUICKVIEW) ) //hmm...
		m_strLastDestPath = DestPath;

	if ( ((OpMode & OPM_SILENT) == OPM_SILENT) || dlgUnpackFiles(DestPath, Move, m_strLastDestPath, bExtractWithoutPath) )
	{
		farPrepareFileName(m_strLastDestPath);

		ArchiveItemArray items; //100??

		GetArchiveItemsToProcess(PanelItem, ItemsNumber, items);

		bResult = Extract(items, m_strLastDestPath, bExtractWithoutPath);

		if ( Move && bResult )
			bResult = Delete(items);
	}

	return bResult;
}
Exemple #10
0
Bool HandleUserCommand(char *ptr, long len)
{
   BYTE type;
   int index;
   Bool success;

   Extract(&ptr, &type, SIZE_TYPE);

   // Dispatch on user command code
   index = 0;
   while (user_handler_table[index].msg_type != 0)
   {
      if (user_handler_table[index].msg_type == type)
      {
	 if (user_handler_table[index].handler != NULL)
	 {                           
	    /* Don't count type byte in length for handler */
	    success = (*user_handler_table[index].handler)(ptr, len - SIZE_TYPE);
	    if (!success)
	    {
	       debug(("Error in user command message of type %d from server\n", type));
	       return False;
	    }
	    return True;
	 }
	 break;
      }
      index++;
   }
   return False;
}
Exemple #11
0
Score EvaluateBishops(uint64_t bb, Phase phase, uint64_t safeDestinations, uint64_t occupancy)
{
	Score ret = 0;

	if (PopCount(bb) >= 2)
	{
		ret += ScalePhase(BISHOP_PAIR_BONUS[0], BISHOP_PAIR_BONUS[1], phase);
	}

	while (bb)
	{
		uint32_t idx = Extract(bb);

		uint32_t mobility = PopCount(Bmagic(idx, occupancy) & safeDestinations);

		ret += ScalePhase(BISHOP_MOBILITY[0][mobility] * MOBILITY_MULTIPLIERS[0],
						  BISHOP_MOBILITY[1][mobility] * MOBILITY_MULTIPLIERS[1], phase);

		if (COLOR == BLACK)
		{
			idx = FLIP[idx];
		}

		ret += ScalePhase(BISHOP_PCSQ[0][idx], BISHOP_PCSQ[1][idx], phase);
	}

	return ret;
}
Exemple #12
0
Score EvaluatePawns(uint64_t bb, Phase phase, uint64_t &pawnAttacksOut)
{
	Score ret = 0;

	while (bb)
	{
		uint32_t idx = Extract(bb);

		if (COLOR == WHITE)
		{
			pawnAttacksOut |= PAWN_ATK[idx][0];
		}
		else
		{
			pawnAttacksOut |= PAWN_ATK[idx][1];
		}

		if (COLOR == BLACK)
		{
			idx = FLIP[idx];
		}

		ret += ScalePhase(PAWN_PCSQ[idx] * PAWN_PCSQ_MULTIPLIERS[0], PAWN_PCSQ[idx] * PAWN_PCSQ_MULTIPLIERS[1], phase);
	}

	return ret;
}
Exemple #13
0
 /** 
  * Constructs a iTime object and initializes it to the time from the argument.
  * 
  * @param time An ephemeris time (ET).
  */
  iTime::iTime (const double time) {
    LoadLeapSecondKernel ();
    p_et = time;
    Extract ();
    p_original = EtString();
    UnloadLeapSecondKernel ();
  }
	CDoubleFeature CSkinFeatureExtractor::Extract(const IRgbImage &img, const int id) const
	{
		// entrance
		CDoubleFeature feature(id, FEATURE_DIM, 0);
		Extract(feature, img);
		return feature;
	}
	void CWaveletTextureFeatureExtractor::Extract(CDoubleFeature& feature, const IRgbImage& img) const
	{
		ATLASSERT(feature.Size() == FEATURE_DIM);
		CFloatFeature _float_feature(UNDEFINED_FEATURE_ID, FEATURE_DIM);
		Extract(_float_feature, img);	
		VxCore::CopyFeatureData(feature, _float_feature);
	}
void FileFormatImplementation::BeginKeywordExtraction()
{
   BeginPrivate();
   m_data->keywords.Clear();
   Extract( m_data->keywords );
   m_data->keywordIterator = m_data->keywords.Begin();
}
Exemple #17
0
HRESULT CSBuffer::Load(CSound *pDS, LONG lSize, FILE *fptr, int Num)
{
    HRESULT rval;
    CHAR* lpCache;
    int length, save;

	// Release all allocated Memory, befor continue
//	m_nBuffers = Num;
	Release( );

    length = lSize;

    // If lSize equals zero get the size of the file.
    if(length == 0)
    {
        // Save the pointer location
        save = ftell(fptr);
        if(ferror(fptr))
            return NULL;

        // Seek to end of file
        fseek(fptr, 0, SEEK_END);
        if(ferror(fptr))
            return NULL;

        // Get the size of the file
        length = ftell(fptr);
        if(ferror(fptr))
            return NULL;

        // Seek back to save position
        fseek(fptr, save, SEEK_SET);
        if(ferror(fptr))
            return NULL;

    }

    // Cache the whole file in memory
    // Allocate memory to hold the data
    lpCache = new CHAR[length];
    if(lpCache == NULL)
        return NULL;

    // Read in the data
    fread(lpCache, 1, length, fptr);
    if(ferror(fptr))
    {
        delete [] lpCache;
        return NULL;
    }

    // Load it from memory.
    rval = Extract(pDS, length, lpCache, Num);

    // Delete the cache
    delete [] lpCache;

	return rval;
}
Exemple #18
0
//---------------------------------------------------------------------------
void __fastcall TTerminalManager::FreeTerminal(TTerminal * Terminal)
{
  try
  {
    // we want the Login dialog to open on auto-workspace name,
    // as set in TCustomScpExplorerForm::FormClose
    if (!FDestroying || !WinConfiguration->AutoSaveWorkspace)
    {
      if (StoredSessions->FindSame(Terminal->SessionData) != NULL)
      {
        WinConfiguration->LastStoredSession = Terminal->SessionData->Name;
      }
    }

    if (ScpExplorer != NULL)
    {
      ScpExplorer->TerminalRemoved(Terminal);
    }

    if (Terminal->Active)
    {
      Terminal->Close();
    }
  }
  __finally
  {
    int Index = IndexOf(Terminal);
    FTerminalList->Clear();
    Extract(Terminal);

    TTerminalQueue * Queue;
    Queue = reinterpret_cast<TTerminalQueue *>(FQueues->Items[Index]);
    FQueues->Delete(Index);
    FTerminationMessages->Delete(Index);

    if (ActiveTerminal && (Terminal == ActiveTerminal))
    {
      if ((Count > 0) && !FDestroying)
      {
        ActiveTerminal = Terminals[Index < Count ? Index : Index - 1];
      }
      else
      {
        ActiveTerminal = NULL;
      }
    }
    else
    {
      SaveTerminal(Terminal);
    }

    // only now all references to/from queue (particularly events to explorer)
    // are cleared
    delete Queue;
    delete Terminal;

    DoTerminalListChanged();
  }
}
Exemple #19
0
HRESULT CSBuffer::Load(CSound* pDS, LONG lSize, CHAR* lpCache, int Num)
{
    HRESULT rval;
    
    rval = Extract(pDS, lSize, lpCache, Num);

    return rval;
}
Exemple #20
0
void Frustum::ExtractFromOGLState() {
  Matrix44f modelview;
  Matrix44f projection;

  glGetFloatv(GL_MODELVIEW_MATRIX, modelview.get_ptr());
  glGetFloatv(GL_PROJECTION_MATRIX, projection.get_ptr());

  Extract(projection * modelview);
}
Exemple #21
0
int main(int argc, char* argv[]){

  FILE *temp;
  int  i = 1;
  char c = (int)0;
  FileNames = malloc(sizeof(char));


  if (argc == 1){
    printf("\n\nHello, bro. It's archivator. Developers: \n");
    printf("    Gusarov.V, Shchurov Al., Karandaev T.\n\n==================\n\n");
    printf("Usage:");
    printf("\n  [FileName...] [ArchiveFile] -a -nosolid(-solid)    |Archive");
    printf("\n  [ArchiveName] [FileName] -e                        |Extract\n\n==================\n");
    return 0;
  }

  //Поиск -а -е в параметрах
  for (i = 1; i < argc; i++){
    if (strcmp(argv[i], "-a") == 0){
      Archive(argv, argc);
      c = 1;
      break;
    }
    if (strcmp(argv[i], "-e") == 0){
      ArchiveName = malloc(sizeof(char) * strlen(argv[1]));
      ArchiveName = argv[1];
      Extract();
      c = 1;
      break;
    }
  }

  //Если отсутствует ключ то мы ищем сигнатуру в первом файле
  if (c == 0){
    temp = fopen(argv[1], "rb");
    if (f_is_upa(temp)){
      ArchiveName = argv[1];
      Extract();
    } else Archive(argv, argc);
    fclose(temp);
  }
  return 0;
}
Exemple #22
0
int Test_Resource(SaHpiSessionIdT session,
		  SaHpiRptEntryT report, callback2_t func)
{
	SaErrorT status;
	int retval = SAF_TEST_UNKNOWN;
	SaHpiHsStateT State;
	SaHpiBoolT Restore = SAHPI_FALSE;

	if ((report.ResourceCapabilities &
	     SAHPI_CAPABILITY_MANAGED_HOTSWAP) &&
	    (report.ResourceCapabilities & SAHPI_CAPABILITY_FRU)) {
		status =
		    saHpiHotSwapStateGet(session, report.ResourceId, &State);
		if (status != SA_OK) {
			e_print(saHpiHotSwapStateGet, SA_OK, status);
			retval = SAF_TEST_UNRESOLVED;
		}
		if (retval == SAF_TEST_UNKNOWN) {
			switch (State) {
			case SAHPI_HS_STATE_ACTIVE:
				TestCase(session, report.ResourceId, &retval,
					 &Restore);
				break;
			case SAHPI_HS_STATE_EXTRACTION_PENDING:
				Activate(session, report.ResourceId, &retval,
					 &Restore);
				TestCase(session, report.ResourceId, &retval,
					 &Restore);
				Extract(session, report.ResourceId, &retval,
					&Restore);
				break;
			case SAHPI_HS_STATE_INSERTION_PENDING:
				Inactivate(session, report.ResourceId, &retval,
					   &Restore);
				TestCase(session, report.ResourceId, &retval,
					 &Restore);
				Insert(session, report.ResourceId, &retval,
				       &Restore);
				break;
			case SAHPI_HS_STATE_INACTIVE:
				TestCase(session, report.ResourceId, &retval,
					 &Restore);
				break;
			default:
				printf
				    ("  Function \"saHpiHotSwapStateGet\" works abnormally!\n");
				printf("  state recieved is not valid!\n");
				retval = SAF_TEST_UNRESOLVED;
			}
		}
	} else {
		// Not a Hot Swap supported Resource
		retval = SAF_TEST_NOTSUPPORT;
	}
	return (retval);
}
Exemple #23
0
void CommandData::ProcessCommand()
{
#ifndef SFX_MODULE

  const wchar *SingleCharCommands=L"FUADPXETK";
  if (Command[0]!=0 && Command[1]!=0 && wcschr(SingleCharCommands,Command[0])!=NULL || *ArcName==0)
    OutHelp(*Command==0 ? RARX_SUCCESS:RARX_USERERROR); // Return 'success' for 'rar' without parameters.

#ifdef _UNIX
  if (GetExt(ArcName)==NULL && (!FileExist(ArcName) || IsDir(GetFileAttr(ArcName))))
    wcsncatz(ArcName,L".rar",ASIZE(ArcName));
#else
  if (GetExt(ArcName)==NULL)
    wcsncatz(ArcName,L".rar",ASIZE(ArcName));
#endif

  if (wcschr(L"AFUMD",*Command)==NULL)
  {
    if (GenerateArcName)
      GenerateArchiveName(ArcName,ASIZE(ArcName),GenerateMask,false);

    StringList ArcMasks;
    ArcMasks.AddString(ArcName);
    ScanTree Scan(&ArcMasks,Recurse,SaveSymLinks,SCAN_SKIPDIRS);
    FindData FindData;
    while (Scan.GetNext(&FindData)==SCAN_SUCCESS)
      AddArcName(FindData.Name);
  }
  else
    AddArcName(ArcName);
#endif

  switch(Command[0])
  {
    case 'P':
    case 'X':
    case 'E':
    case 'T':
    case 'I':
      {
        CmdExtract Extract(this);
        Extract.DoExtract();
      }
      break;
#ifndef SILENT
    case 'V':
    case 'L':
      ListArchive(this);
      break;
    default:
      OutHelp(RARX_USERERROR);
#endif
  }
  if (!BareOutput)
    mprintf(L"\n");
}
Exemple #24
0
bool GetReparsePointInfo(const string& Object, string &strDestBuff,LPDWORD ReparseTag)
{
	block_ptr<REPARSE_DATA_BUFFER> rdb(MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
	if (!GetREPARSE_DATA_BUFFER(Object, rdb.get()))
		return false;

	if (ReparseTag)
		*ReparseTag=rdb->ReparseTag;

	const auto& Extract = [&](const auto& Buffer)
	{
		const wchar_t *PathBuffer = nullptr;
		auto NameLength = Buffer.PrintNameLength / sizeof(wchar_t);

		if (NameLength)
		{
			PathBuffer = &Buffer.PathBuffer[Buffer.PrintNameOffset / sizeof(wchar_t)];
		}
		else
		{
			NameLength = Buffer.SubstituteNameLength / sizeof(wchar_t);
			PathBuffer = &Buffer.PathBuffer[Buffer.SubstituteNameOffset / sizeof(wchar_t)];
		}

		if (!NameLength)
			return false;

		strDestBuff.assign(PathBuffer, NameLength);
		return true;
	};

	switch (rdb->ReparseTag)
	{
	case IO_REPARSE_TAG_SYMLINK:
		return Extract(rdb->SymbolicLinkReparseBuffer);

	case IO_REPARSE_TAG_MOUNT_POINT:
		return Extract(rdb->MountPointReparseBuffer);

	default:
		return false;
	}
}
Exemple #25
0
int APIENTRY ZIPExtract(char* pstrToExt, char* pstrSaveAs)
{
	if (g_uf)
	{
		CreateDir(pstrSaveAs);
		if (!IsDir(pstrSaveAs))
			Extract(pstrToExt, pstrSaveAs, g_uf);
	}
	return 1;
}
Exemple #26
0
    uint32_t GenericBsa::CalcChecksum(const std::string& assetPath) const {
        const uint8_t * data;
        size_t dataSize;
        Extract(assetPath, &data, &dataSize);

        //Calculate the checksum now.
        boost::crc_32_type result;
        result.process_bytes(data, dataSize);

        return result.checksum();
    }
Exemple #27
0
char *GlistOp(char *glist, char *op){
	if(NoBracket(glist)){
		return glist;
	}
	else{
		Extract(glist, *op);
		int i;
		for(i = 0; *(op + i); i++){
			*(op + i) = *(op + i + 1);
		}
		return GlistOp(glist, op);
	}
}
void
astPlayerShip::Despawn()
{
	Extract();
	SetCollisionsActive(false);

	m_emitter->SetSpawnRate(0.0f);
	m_emitter->SpawnImmediateBurst(60, GetPosition(), 10.0f, 3.0f, vsColor::Blue);

	m_isSpawned = false;
	m_delayBeforeSpawn = 2.0f;	// no respawning for at least two seconds.
	m_timeSinceSpawn = 0.f;
}
Exemple #29
0
Bool HandleGameStart(char *ptr, long len)
{
   char *start = ptr;
   BYTE player_num;
   
   // If we've already received our game object number, skip
   if (game_obj != 0)
      return False;

   Extract(&ptr, &game_obj, SIZE_ID);
   Extract(&ptr, &player_num, 1);
   // debug(("Chess got game start, object = %d, player # = %d\n", game_obj, player_num));

   len -= (ptr - start);
   if (len != 0)
      return False;

   switch (player_num)
   {
   case 1:
      b.color = WHITE;
      if (hChessDlg != NULL)
	 EnableWindow(GetDlgItem(hChessDlg, IDC_RESIGN), TRUE);
      break;
   case 2:
      b.color = BLACK;
      if (hChessDlg != NULL)
	 EnableWindow(GetDlgItem(hChessDlg, IDC_RESIGN), TRUE);
      break;
   default:
      b.color = OBSERVER;
      break;
   }

   // Display player's name in dialog
   ChessGotPlayerName(player_num, LookupRsc(c->player->name_res));
   
   return True;
}
Exemple #30
0
 /** 
  * Constructs a iTime object and initializes it to the time from the argument.
  * 
  * @param time A time string formatted in standard UTC or similar format. 
  *             Example:"2000/12/31 23:59:01.6789" or "2000-12-31T23:59:01.6789"
  */
  iTime::iTime (const std::string &time) {
    LoadLeapSecondKernel ();
  
    // Convert the time string to a double ephemeris time
    SpiceDouble et;
    str2et_c (time.c_str(), &et);
  
    p_et = et;
    p_original = time;
  
    Extract ();
    UnloadLeapSecondKernel ();
  }