Exemplo n.º 1
0
void GameRecord::UpdateRecordItem(GameRecord::RecordItem *item, const GameRecordInfo& recordInfo)
{
    //刷新第几手牌
    char record[128] = {0};
    sprintf(record, "第%d手牌", recordInfo.m_uIdx);
    SetLabelString(item->m_pLableRecordNum, record);

    //刷新房间名称
    //char roomName[128]={0};
	//sprintf(record,"%s",recordInfo.m_strTableName.c_str()) ;
    sprintf(record,"%s  ( %d人 )  :%.0f/%.0f   扑克牌:...", recordInfo.m_strTableName.c_str(), recordInfo.m_uMaxPlayer, recordInfo.m_dSmallBlind, recordInfo.m_dBigBlind);
    SetLabelStringWithBoundWidth(item->m_pLableRoomName, record, 420);

    //刷新盈利
    std::string profit = FormatCash4(recordInfo.m_dWinLost);
    SetLabelString(item->m_pLableProfit, profit);

    //刷新游戏时间
    std::string strTime = CalculateTime(recordInfo.m_dTime);
    SetLabelString(item->m_pLableGameTime, strTime);

    
    /*int cardLeft = recordInfo.m_cbHandCard[0];
    int cardRight = recordInfo.m_cbHandCard[1];
    if (cardLeft < 0)cardLeft = 0;
    if (cardRight < 0)cardRight = 0;*/
    item->m_pSpriteHandCardL->SetFrameIdx(GetCardFrameIdx(recordInfo.m_cbHandCard[0]));
    item->m_pSpriteHandCardR->SetFrameIdx(GetCardFrameIdx(recordInfo.m_cbHandCard[1]));
}
Exemplo n.º 2
0
int main()
{
	int passwordCount = GetInt();
	char ** passwords = (char**)malloc(passwordCount * sizeof(char*));
	unsigned long long totalTime = 0;
	int totalCracked = 0;
	// for each line
	for (size_t i = 0; i < passwordCount; i++)
	{
		//parse it
		char * line = GetString();
		unsigned long long timeLimit;
		char *token = strtok(line, " ");
		timeLimit = strtoull(token, NULL, 0);
		totalTime += timeLimit;
		token = strtok(NULL, " ");
		passwords[i] = (char*)malloc(strlen(token) + 1);
		strcpy(passwords[i], token);
				
	}
	/*for (size_t i = 0; i < passwordCount; i++)
	{
		printf("%s\n", passwords[i]);
	}*/
	for (size_t i = 0; i < passwordCount; i++)
	{
		int time = CalculateTime(passwords[i]);
		//compare
		if(time <=totalTime)
		{
			totalCracked++;
			printf("Password \"%s\" successfully cracked!\n", passwords[i]);
		}
		else
		{
			printf("Could not crack password \"%s\". %lu more seconds needed.\n",passwords[i],time-totalTime);
		}
	}
	double successRate = (double)totalCracked / passwordCount;
	printf("%.2f%% of all passwords were cracked\n", successRate*100);
	
	return 0;
}
Exemplo n.º 3
0
void EventProcessor::Update(uint32 p_time)
{
    // update time
    m_time += p_time;

    // main event loop
    std::multimap<uint64, BasicEvent*>::iterator i;
    while (((i = m_events.begin()) != m_events.end()) && i->first <= m_time)
    {
        // get and remove event from queue
        BasicEvent* event = i->second;
        m_events.erase(i);

        if (event->IsRunning())
        {
            if (event->Execute(m_time, p_time))
            {
                // completely destroy event if it is not re-added
                delete event;
            }
            continue;
        }

        if (event->IsAbortScheduled())
        {
            event->Abort(m_time);
            // Mark the event as aborted
            event->SetAborted();
        }

        if (event->IsDeletable())
        {
            delete event;
            continue;
        }

        // Reschedule non deletable events to be checked at
        // the next update tick
        AddEvent(event, CalculateTime(1), false);
    }
}
Exemplo n.º 4
0
void CD3DApp::Loop(void (*loopFunction)())
{
	MSG msg;
	ZeroMemory(&msg, sizeof(msg));
	while (msg.message != WM_QUIT) {
		if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
			TranslateMessage(&msg);
			DispatchMessage(&msg); }
		else {
			if (m_bPaused)
				Sleep(80);
			else {
				CalculateTime(); 
				PollKeyboard();
				PollMouse();

				loopFunction();
			}
		}
	}
}
Exemplo n.º 5
0
/**
  * @brief  This function handles RTC_IRQHandler .
  * @param  None
  * @retval : None
  */
void RTC_IRQHandler(void)
{
    NVIC_ClearPendingIRQ(RTC_IRQn);
    RTC_ClearITPendingBit(RTC_IT_SEC);

    CalculateTime();
    alarm_check(alarm_buffer_ptr);

    /* If counter is equal to 86399: one day was elapsed */
    /* This takes care of date change and resetting of counter in case of
    power on - Run mode/ Main supply switched on condition*/
    if(RTC_GetCounter() == 86399)
    {
        /* Wait until last write operation on RTC registers has finished */
        RTC_WaitForLastTask();
        /* Reset counter value */
        RTC_SetCounter(0x0);
        /* Wait until last write operation on RTC registers has finished */
        RTC_WaitForLastTask();

        /* Increment the date */
        DateUpdate();
    }
}
int main ( void )
{
	char cSystem = '0';
	int Array1[ 10000 ], Array2[ 10000 ];

	printf ( "Welcome to CS460 HW 09 solution!\n" );

	for ( cSystem = UserMenu ( &cSystem ); cSystem - 48; cSystem = UserMenu ( &cSystem ) )
	{
		switch ( cSystem - 48 )
		{
			case 1:
				PopulateArray ( Array1 );//populate array
			break;
			case 2:
				CopyArrays ( Array1, Array2 );//copy array
			break;
			case 3:
				printf ( "Array 1:\n" );
				DisplayArray ( Array1 );//display array1
				printf ( "\nArray 2:\n" );
				DisplayArray ( Array2 );//display array2
				printf ( "\n" );
			break;
			case 4:
				CalculateTime ( Array1 );//calculate bubble sort time
			break;
			case 5:
				printf ( "Quick sort time is %lf\n", QsortTime );//print QsortTime
			break;
			
		}
	}
	Exit ();
	return 0;
}
Exemplo n.º 7
0
/*******************************************************************************
* Function Name  : RTC_Application
* Description    : RTC Application runs in while loop
* Input          : None
* Output         : Displays Time, Date and Alarm Status
* Return         : None
*******************************************************************************/
void RTC_Application(void)
{
  u8 u8_ReturnValue;

  CalculateTime();
  
  if(u8_TimeDateDisplay==0)
  {
    //DisplayTime();
  }

  if(u8_DisplayDateFlag==1 && u8_TimeDateDisplay==0)
  {
    //DisplayDate();
    u8_DisplayDateFlag=0;
  }

  if(u8_AlarmStatus==1)
  {
    //DisplayAlarm();
    GPIO_SetBits(GPIOC, GPIO_Pin_6);
    u32_Dummy=RTC_GetCounter();
    u8_AlarmStatus=2;
  }
  if(((RTC_GetCounter()-u32_Dummy) == 4) && (u8_AlarmStatus==2))
  {
    GPIO_ResetBits(GPIOC, GPIO_Pin_6);
    //SelIntExtOnOffConfig(ENABLE);
    //RightLeftIntExtOnOffConfig(ENABLE);
    //UpDownIntOnOffConfig(ENABLE);
    //MenuInit();
    u32_Dummy=0;
    u8_AlarmStatus = 0;
  }

  if(u8_TamperEvent==1) /* Tamper event is detected */
  {
    u8_TamperNumber = u8_TamperNumber + 1;
    BKP_WriteBackupRegister(BKP_DR5,u8_TamperNumber);
    BKP_WriteBackupRegister(BKP_DR1, CONFIGURATION_DONE);
    BKP_WriteBackupRegister(BKP_DR2,s_DateStructVar.u8_Month);
    BKP_WriteBackupRegister(BKP_DR3,s_DateStructVar.u8_Day);
    BKP_WriteBackupRegister(BKP_DR4,s_DateStructVar.u16_Year);
    BKP_WriteBackupRegister(BKP_DR9,s_AlarmDateStructVar.u8_Day);
    BKP_WriteBackupRegister(BKP_DR8,s_AlarmDateStructVar.u8_Month);
    BKP_WriteBackupRegister(BKP_DR10,s_AlarmDateStructVar.u16_Year);
    BKP_WriteBackupRegister(BKP_DR6,u8_ClockSource);
    BKP_WriteBackupRegister(BKP_DR7,u16_SummerTimeCorrect);
    /*
    u8_ReturnValue=EE_WriteVariable(u8_TamperNumber);
    
    if(u8_ReturnValue==PAGE_FULL)
    {
      u8_ReturnValue=EE_WriteVariable(u8_TamperNumber);
    }
    
    u8_ReturnValue=EE_WriteVariable(s_DateStructVar.u8_Day);
    u8_ReturnValue=EE_WriteVariable(s_DateStructVar.u8_Month);
    u8_ReturnValue=EE_WriteVariable((s_DateStructVar.u16_Year)/100);
    u8_ReturnValue=EE_WriteVariable((s_DateStructVar.u16_Year)%100);
    u8_ReturnValue=EE_WriteVariable((s_TimeStructVar.u8_HourHigh*10)+\
                    s_TimeStructVar.u8_HourLow);
    u8_ReturnValue=EE_WriteVariable((s_TimeStructVar.u8_MinHigh*10)+\
                    s_TimeStructVar.u8_MinLow);
    u8_ReturnValue=EE_WriteVariable((s_TimeStructVar.u8_SecHigh*10)+\
                    s_TimeStructVar.u8_SecLow);*/
    while(!(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13)))
    {
    }
    
    u8_TamperEvent=0;
    BKP_TamperPinCmd(ENABLE);
  }
  
  if(u8_BatteryRemoved != 0) /* Battery tamper is detected */
  {
    u8_TamperNumber = u8_TamperNumber + 1;
    BKP_WriteBackupRegister(BKP_DR5,u8_TamperNumber);
    /*
    u8_ReturnValue=EE_WriteVariable(u8_TamperNumber);
    
    if(u8_ReturnValue==PAGE_FULL)
    {
      u8_ReturnValue=EE_WriteVariable(u8_TamperNumber);
    }
    
    u8_ReturnValue=EE_WriteVariable(s_DateStructVar.u8_Day);
    u8_ReturnValue=EE_WriteVariable(s_DateStructVar.u8_Month);
    u8_ReturnValue=EE_WriteVariable((s_DateStructVar.u16_Year)/100);
    u8_ReturnValue=EE_WriteVariable((s_DateStructVar.u16_Year)%100);
    u8_ReturnValue=EE_WriteVariable((s_TimeStructVar.u8_HourHigh*10)\
                    +s_TimeStructVar.u8_HourLow);
    u8_ReturnValue=EE_WriteVariable((s_TimeStructVar.u8_MinHigh*10)\
                    +s_TimeStructVar.u8_MinLow);
    if(u8_BatteryRemoved==1)
    {
      u8_ReturnValue=EE_WriteVariable(BATTERY_REMOVED);
      u8_BatteryRemoved=0;
    }
    else if(u8_BatteryRemoved==2)
    {
      u8_ReturnValue=EE_WriteVariable(BATTERY_RESTORED);
      u8_BatteryRemoved=0;
    }
*/
    BKP_TamperPinCmd(ENABLE);
  }
}
Exemplo n.º 8
0
int Time::Minute() const
{
    CalculateTime();
    return ((SYSTEMTIME*)cache)->wMinute;
}
Exemplo n.º 9
0
int Time::Hour() const
{
    CalculateTime();
    return ((SYSTEMTIME*)cache)->wHour;
}
Exemplo n.º 10
0
int Time::Day() const
{
    CalculateTime();
    return ((SYSTEMTIME*)cache)->wDay;
}
Exemplo n.º 11
0
int Time::Month() const
{
    CalculateTime();
    return ((SYSTEMTIME*)cache)->wMonth;
}
Exemplo n.º 12
0
int Time::Year() const
{
    CalculateTime();
    return ((SYSTEMTIME*)cache)->wYear;
}
Exemplo n.º 13
0
int Time::MilliSecond() const
{
    CalculateTime();
    return ((SYSTEMTIME*)cache)->wMilliseconds;
}
Exemplo n.º 14
0
int Time::Second() const
{
    CalculateTime();
    return ((SYSTEMTIME*)cache)->wSecond;
}
Exemplo n.º 15
0
/*******************************************************************************************

  > BOOL BitmapPreviewData::GenerateHTMLStub(BrowserPreviewOptions BrowserOptions)
  
	Author: 	Stefan_Stoykov (Xara Group Ltd) <*****@*****.**> 
	Created:	24/6/97
	Inputs: 	BrowserOptions - the options for generating the html page
	Purpose:	Generate a html file which includes our bitmap, together with some other optional 
				stuff. Used for browser preview.
				
*******************************************************************************************/
BOOL BitmapPreviewData::GenerateHTMLStub(BrowserPreviewOptions BrowserOptions)
{
PORTNOTE("other","Removed _R(IDD_TIMAPOPTIONS) - isn't wanted yet")
#ifndef EXCLUDE_FROM_XARALX
	// sanity checks
	
	// check for export options
	
	ERROR3IF(m_pOptions == NULL, "BitmapPreviewData::GenerateHTMLStub - need export options");
	if (m_pOptions == NULL) // we need export options
		return FALSE;
	
	// get the path for the exported bitmap from the options
	PathName TempPath = m_pOptions->GetPathName();
	
	// check for exported bitmap
	ERROR3IF((m_pOptions->HasTempFile() == FALSE) || (TempPath.IsValid() == FALSE), 
		"BitmapPreviewData::GenerateHTMLStub - need exported bitmap");
	if ((m_pOptions->HasTempFile() == FALSE) || (TempPath.IsValid() == FALSE)) 
		return FALSE;
	
	// delete the previous temp file, if any
	if (m_pTempHTMLPath != NULL)
		FileUtil::DeleteFile(m_pTempHTMLPath);
	else
		m_pTempHTMLPath = new PathName;
	
	// safety check
	if (m_pTempHTMLPath == NULL)
		return FALSE;
	
	// create a new temp file 
	if (FileUtil::GetTemporaryPathName( _T("htm"),m_pTempHTMLPath) == FALSE)
	{
		delete m_pTempHTMLPath;
		m_pTempHTMLPath = NULL;
		
		return FALSE;
	}
	
	// start creating the html page
	
	// create a disk file
	CCDiskFile TempDiskFile(1024, FALSE, TRUE);
	
	// get path name to server, so we can find the logo bitmaps
	CString str;
	AfxGetModuleShortFileName(AfxGetInstanceHandle(), str);
	String_256 strPathName(str.GetBuffer(0));
	
	// create a path name object from the program name
	PathName ProgramPath(strPathName);
	
	try
	{
		// open it for reading
		if (!TempDiskFile.open(*m_pTempHTMLPath, ios::out))
			return FALSE;
		
		// output header
		String_256 s(_R(IDS_HTML_HEAD));
		TempDiskFile.write(s);
		
		// set the background attributes
		switch (BrowserOptions.m_Background)
		{
		case BROWSER_BGR_DOC:
			{
				// set the background from the document page
				if (!SetBackgroundFromPage(TempDiskFile, BrowserOptions.m_pSpread))
					ERROR3("Setting the html background from the document page failed\n");
			}
			break;
			
		case BROWSER_BGR_CHECKER:
			{
				// display the checkered bitmap as background
				
				// get the checkered bitmap name
				String_256 Checker(_R(IDS_HTML_CHECKER));
				
				// set it in the path
				ProgramPath.SetFileNameAndType(Checker);
				
				// set the checkered bitmap as background image
				s.MakeMsg(_R(IDS_CHECK_BACK), (TCHAR *)ProgramPath.GetWebAddress());
				TempDiskFile.write(s);
			}
			break;
			
		case BROWSER_BGR_BITMAP:
			{
				// set our bitmap as background image
				s.MakeMsg(_R(IDS_BITMAPED_BACKGROUND), (TCHAR *)TempPath.GetWebAddress());
				TempDiskFile.write(s);
				
				
			}
			break;
			
		case BROWSER_BGR_NONE:
			{
				String_256 background(_R(IDS_PLAIN_BACKGROUND));
				TempDiskFile.write(background);
			}
			
			break;
			
		default:
			ERROR3("Unknown type of BrowserOptions.m_Background");
			break;
		} // end of switch(BrowserOptions.m_Background) block
		
		// Get a pointer to the actual bitmap so that we can get some details from it.
		//		OILBitmap *pOilBitmap = m_pBitmap->ActualBitmap;
		//		ERROR3IF(pOilBitmap == NULL,"BitmapPreviewData::GenerateBitmapInfoStrings NULL oil bitmap pointer");
		
		// Get the details from the specified bitmap
		//		BitmapInfo BmInfo;
		//		pOilBitmap->GetInfo(&BmInfo);
		
		// output our bitmap, but only if it wasn't already set as background
		String_256 s2(_R(IDS_PAGE_TITLE));
		TempDiskFile.write(s2);
		
		if (BrowserOptions.m_Background != BROWSER_BGR_BITMAP)
		{
			// output the bitmap
			
			if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER)
			{
				// GIF animation
				s.MakeMsg(_R(IDS_DISPLAY_PIC), (const TCHAR *)TempPath.GetFileName());
			}
			else
			{
				if( m_pOptions->GetFilterNameStrID() == _R(IDN_FILTERNAME_GIF) ||
					m_pOptions->GetFilterNameStrID() == _R(IDS_JPG_EXP_FILTERNAME) ||
					m_pOptions->GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP) )
				{
					s.MakeMsg(_R(IDS_DISPLAY_BMP), (const TCHAR *)TempPath.GetFileName());
				}
				else
				if( m_pOptions->GetFilterNameStrID() == _R(IDS_FILTERNAME_PNG) )
					s.MakeMsg(_R(IDS_DISPLAY_PNG), (const TCHAR *)TempPath.GetFileName());
			}	
			
			TempDiskFile.write(s);
		}
		else
		{
			s.MakeMsg(_R(IDS_EMPTY_BOX));
			TempDiskFile.write(s);
			
		}
		
		switch (m_pOptions->GetFilterNameStrID())
		{
		case _R(IDT_FILTERNAME_BMP):
			s2.MakeMsg(_R(IDS_BMP_MESSAGE));
			s.MakeMsg(_R(IDS_WARNING_BOX), (TCHAR *)s2);
			TempDiskFile.write(s);
			break;
		case _R(IDS_FILTERNAME_PNG):
			s2.MakeMsg(_R(IDS_PNG_MESSAGE));
			s.MakeMsg(_R(IDS_WARNING_BOX), (TCHAR *)s2);
			TempDiskFile.write(s);
			break;
		} // end of switch(m_pOptions->GetFilterNameStrID())
		
		s.MakeMsg(_R(IDS_DETAILS_BUILD));
		TempDiskFile.write(s);
		
		// output the bitmap info, if requested
		if (BrowserOptions.m_bInfo != FALSE)
		{
			String_64 ImageSize;
			String_64 FileSize;
			BOOL m_bTransparent = FALSE;
			INT32 count;
			count=0;
			// generate the info strings
			
			if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER)
			{
				// This is actually the export animated GIF using the frame gallery system
				MakeBitmapExportOptions* pMkBOptions = (MakeBitmapExportOptions*)m_pOptions;
				ERROR3IF(!pMkBOptions->IS_KIND_OF(MakeBitmapExportOptions), "pMkBOptions isn't");
				
				PALETTE Palette = PAL_OPTIMISED;
				DITHER DitherType;
				UINT32 colDepth;
				String_64 sPalette;
				String_64 Dither;
				UINT32 NoOfColours;
				
				NoOfColours=m_pOptions->GetNumColsInPalette();
				//						Palette = pMkBOptions->GetPalette();
				DitherType = pMkBOptions->GetDither();
				colDepth = pMkBOptions->GetDepth();
				
				s2.MakeMsg(_R(IDS_ANIMATED_GIF));
				
				if (pMkBOptions->WantTransparent())
				{
					s2.MakeMsg(_R(IDS_TRANSPARENT),"animated GIF");
				}
				
				s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
				TempDiskFile.write(s);
				
				switch (Palette)
				{
				case PAL_OPTIMISED:
					sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL));
					break;
				case PAL_BROWSER:
				case PAL_STANDARD:
					sPalette.MakeMsg(_R(IDS_BROWSER_PAL));
					break;
				case PAL_GLOBALOPTIMISED:
					sPalette.MakeMsg(_R(IDS_GLOBAL_OPT));
					break;
					
				}
				
				if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) )
				{
					NoOfColours = 216;
				}
				
				switch (colDepth)
				{
				case 32:
				case 24:
					s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth);
					break;
				case 8:
					{
						// Include the transparent colour in the colour depth check
						UINT32 RealNumberOfColours = NoOfColours;
						if (colDepth <= 8 && pMkBOptions->WantTransparent())
						{
							UINT32 MaxColours = UINT32(pow(2,colDepth));
							RealNumberOfColours++;
							if (RealNumberOfColours > MaxColours)
								RealNumberOfColours = MaxColours;
						}
						// We say 8 but we really mean the number of colours deep
						// We cannot say 2 colours = 2bpp as we save it as 10 colours due
						// to having 1 transparent colour and the usual lets pick 10 as the
						// transparent colour. Cannot allow the user to choose 1 as the code
						// then outputs 8bpp as GRenderOptPalette::GetOptimisedPalette has the
						// test if (ReservedColours < NumColours), which fails.
						/* if (RealNumberOfColours <= 2)
						s2.MakeMsg(_R(IDS_PALETTEINFO),2,NoOfColours,(const TCHAR*)sPalette);
						else */
						if (RealNumberOfColours <= 16)
							s2.MakeMsg(_R(IDS_PALETTEINFO),4,NoOfColours,(const TCHAR*)sPalette);
						else
							s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);
						break;
					}
				case 1:
					s2.MakeMsg(_R(IDS_MONO),colDepth);
					break;
				case 4:
				default:
					s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);					
					break;
				}
				
				TempDiskFile.write(s2); 				
				
				s.MakeMsg(_R(IDS_NODITHER));
				switch (DitherType)
				{
				case XARADITHER_ORDERED:
				case XARADITHER_ORDERED_GREY:
					Dither.MakeMsg(_R(IDS_DITH_ORDER));
					s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
					break;
				case XARADITHER_ERROR_DIFFUSION:
				case XARADITHER_SIMPLE:
					Dither.MakeMsg(_R(IDS_DITH_ERROR));
					s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
					break;
				case XARADITHER_NONE:
					s.MakeMsg(_R(IDS_NODITHER));
					break;
				}
				
				TempDiskFile.write(s);
			} // if (m_pOptions->GetFilterType() == MAKE_BITMAP_FILTER) block ends
			else
			{
				switch (m_pOptions->GetFilterNameStrID())
				{
				case _R(IDN_FILTERNAME_GIF):
					{
						GIFExportOptions* pGIFOptions = (GIFExportOptions*)m_pOptions;
						ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
						PALETTE Palette = PAL_OPTIMISED;
						DITHER DitherType;
						UINT32 colDepth;
						String_64 sPalette;
						String_64 Dither;
						UINT32 NoOfColours;
						
						NoOfColours=m_pOptions->GetNumColsInPalette();
						//						Palette = pGIFOptions->GetPalette();
						DitherType = pGIFOptions->GetDither();
						colDepth = pGIFOptions->GetDepth();
						
						
						if (pGIFOptions->WantTransparent())
							count=count+1;
						
						if (pGIFOptions->WantInterlaced())
							count=count+2;
						
						s.MakeMsg(_R(IDS_GIF));
						s2.MakeMsg(_R(IDS_A), (const TCHAR*)s);
						
						switch (count)
						{
						case 1:
							s2.MakeMsg(_R(IDS_TRANSPARENT),"GIF");
							break;
						case 2:
							s2.MakeMsg(_R(IDS_INTERLACED),"GIF");
							break;
						case 3:
							s2.MakeMsg(_R(IDS_INTER_TRANS),"GIF");
							break;
						case 0:
							break;
						}
						
						s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
						TempDiskFile.write(s);
						
						switch (Palette)
						{
						case PAL_OPTIMISED:
							sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL));
							break;
						case PAL_BROWSER:
						case PAL_STANDARD:
							sPalette.MakeMsg(_R(IDS_BROWSER_PAL));
							break;
						case PAL_GLOBALOPTIMISED:
							sPalette.MakeMsg(_R(IDS_GLOBAL_OPT));
							break;
							
						}
						
						if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) )
						{
							NoOfColours = 216;
						}
						
						s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);					
						
						if (colDepth == 8)
							s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);
						
						if (colDepth == 1)
							s2.MakeMsg(_R(IDS_MONO),colDepth);
						
						if (colDepth > 8)
							s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth);
						
						TempDiskFile.write(s2); 				
						
						s.MakeMsg(_R(IDS_NODITHER));
						switch (DitherType)
						{
						case XARADITHER_ORDERED:
						case XARADITHER_ORDERED_GREY:
							Dither.MakeMsg(_R(IDS_DITH_ORDER));
							s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
							break;
						case XARADITHER_ERROR_DIFFUSION:
						case XARADITHER_SIMPLE:
							Dither.MakeMsg(_R(IDS_DITH_ERROR));
							s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
							break;
						case XARADITHER_NONE:
							s.MakeMsg(_R(IDS_NODITHER));
							break;
						}
						
						TempDiskFile.write(s);
						
						
					} // end case _R(IDN_FILTERNAME_GIF)
					break;
				case _R(IDS_JPG_EXP_FILTERNAME): 
					{
						JPEGExportOptions* pJPEGOptions = (JPEGExportOptions *)m_pOptions;
						ERROR3IF(!pJPEGOptions->IS_KIND_OF(JPEGExportOptions), "pJPEGOptions isn't");
						INT32 Quality = pJPEGOptions->GetQuality();	// Default Quality
						BOOL Progressive = pJPEGOptions->DoAsProgressive();
						if (Quality > 100)
							Quality = 100;
						
						
						s.MakeMsg(_R(IDS_JPEG));
						s2.MakeMsg(_R(IDS_A), (const TCHAR*)s);
						
						if (Progressive)
							s2.MakeMsg(_R(IDS_PROGRESSIVE));
						
						s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
						TempDiskFile.write(s);
						
						
						s.MakeMsg(_R(IDS_JCOMPRESSION),Quality);
						TempDiskFile.write(s);					
					} // end case _R(IDS_JPG_EXP_FILTERNAME)
					break;
					
				case _R(IDT_FILTERNAME_BMP):
					{
						BMPExportOptions* pBMPOptions = (BMPExportOptions*)m_pOptions;
						ERROR3IF(!pBMPOptions->IS_KIND_OF(BMPExportOptions), "pBMPOptions isn't");
						PALETTE Palette;
						DITHER DitherType;
						UINT32 colDepth;
						String_64 sPalette;
						String_64 Dither;
						UINT32 NoOfColours;
						
						NoOfColours=m_pOptions->GetNumColsInPalette();
						Palette = pBMPOptions->GetPalette();
						DitherType = pBMPOptions->GetDither();
						colDepth = pBMPOptions->GetDepth();
						
						s.MakeMsg(_R(IDS_BMP));
						s2.MakeMsg(_R(IDS_A), (const TCHAR*)s);
						
						s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
						TempDiskFile.write(s);
						
						switch (Palette)
						{
						case PAL_OPTIMISED:
							sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL));
							break;
						case PAL_BROWSER:
						case PAL_STANDARD:
							sPalette.MakeMsg(_R(IDS_BROWSER_PAL));
							break;
						case PAL_GLOBALOPTIMISED:
							sPalette.MakeMsg(_R(IDS_GLOBAL_OPT));
							break;
						}
						
						if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) )
						{
							NoOfColours = 216;
						}
						
						if (colDepth == 8 && NoOfColours > 256)
							NoOfColours = 256;
						
						s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);					
						
						if (colDepth == 8)
							s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);
						
						if (colDepth == 1)
							s2.MakeMsg(_R(IDS_MONO),colDepth);
						
						if (colDepth > 8)
							s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth);
						
						TempDiskFile.write(s2); 				
						
						s.MakeMsg(_R(IDS_NODITHER));
						switch (DitherType)
						{
						case XARADITHER_ORDERED:
						case XARADITHER_ORDERED_GREY:
							Dither.MakeMsg(_R(IDS_DITH_ORDER));
							s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
							break;
						case XARADITHER_ERROR_DIFFUSION:
						case XARADITHER_SIMPLE:
							Dither.MakeMsg(_R(IDS_DITH_ERROR));
							s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
							break;
						case XARADITHER_NONE:
							s.MakeMsg(_R(IDS_NODITHER));
							break;
						}
						
						TempDiskFile.write(s);
					} // end case _R(IDT_FILTERNAME_BMP)
					break;
					
				case _R(IDS_FILTERNAME_PNG):
					{
						PNGExportOptions* pPNGOptions = (PNGExportOptions*)m_pOptions;
						ERROR3IF(!pPNGOptions->IS_KIND_OF(PNGExportOptions), "pPNGOptions isn't");
						PALETTE Palette = PAL_OPTIMISED;
						DITHER DitherType;
						UINT32 colDepth;
						String_64 sPalette;
						String_64 Dither;
						UINT32 NoOfColours;
						
						NoOfColours=m_pOptions->GetNumColsInPalette();
						
						//						Palette = pPNGOptions->GetPalette();
						DitherType = pPNGOptions->GetDither();
						colDepth = pPNGOptions->GetDepth();
						
						
						if (pPNGOptions->WantTransparent())
							count=count+1;
						
						if (pPNGOptions->WantInterlaced())
							count=count+2;
						
						s.MakeMsg(_R(IDS_PNG));
						s2.MakeMsg(_R(IDS_A), (const TCHAR*)s);
						
						switch (count)
						{
						case 1:
							s2.MakeMsg(_R(IDS_TRANSPARENT),"PNG");
							break;
						case 2:
							s2.MakeMsg(_R(IDS_INTERLACED),"PNG");
							break;
						case 3:
							s2.MakeMsg(_R(IDS_INTER_TRANS),"PNG");
							break;
						case 0:
							break;
						}
						
						s.MakeMsg(_R(IDS_TEXTLINE_BR),(const TCHAR*)s2);
						TempDiskFile.write(s);
						
						switch (Palette)
						{
						case PAL_OPTIMISED:
							sPalette.MakeMsg(_R(IDS_OPTIMISED_PAL));
							break;
						case PAL_BROWSER:
						case PAL_STANDARD:
							sPalette.MakeMsg(_R(IDS_BROWSER_PAL));
							break;
						case PAL_GLOBALOPTIMISED:
							sPalette.MakeMsg(_R(IDS_GLOBAL_OPT));
							break;
						}
						
						if (colDepth == 8 && (Palette == PAL_STANDARD || Palette == PAL_BROWSER) )
						{
							NoOfColours = 216;
						}
						
						s2.MakeMsg(_R(IDS_PALETTEINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);					
						
						if (colDepth == 8)
							s2.MakeMsg(_R(IDS_AN_PALINFO),colDepth,NoOfColours,(const TCHAR*)sPalette);
						
						if (colDepth == 1)
							s2.MakeMsg(_R(IDS_MONO),colDepth);
						
						if (colDepth > 8)
							s2.MakeMsg(_R(IDS_TRUECOLOUR),colDepth);
						
						TempDiskFile.write(s2); 				
						
						s.MakeMsg(_R(IDS_NODITHER));
						switch (DitherType)
						{
						case XARADITHER_ORDERED:
						case XARADITHER_ORDERED_GREY:
							Dither.MakeMsg(_R(IDS_DITH_ORDER));
							s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
							break;
						case XARADITHER_ERROR_DIFFUSION:
						case XARADITHER_SIMPLE:
							Dither.MakeMsg(_R(IDS_DITH_ERROR));
							s.MakeMsg(_R(IDS_DITHERING),(const TCHAR*) Dither);
							break;
						case XARADITHER_NONE:
							s.MakeMsg(_R(IDS_NODITHER));
							break;
						}
						
						TempDiskFile.write(s);
					} // end case _R(IDS_FILTERNAME_PNG)
					
					break;
				} // end switch (m_pOptions->GetFilterNameStrID())
			} // end else block
			
			GenerateBitmapInfoStrings(ImageSize, FileSize);
			
			// output the bitmap info
			s.MakeMsg(_R(IDS_HTML_INFO1), (TCHAR *)ImageSize);
			TempDiskFile.write(s);
			
			// output the bitmap file size info
			s.MakeMsg(_R(IDS_HTML_INFO2), (TCHAR *)FileSize);
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_CLOSE_CENTER));
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_TDTR_CLOSE));
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_BANNER_BOX));
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_SPEED_BUILD));
			TempDiskFile.write(s);
			//			s.MakeMsg(_R(IDS_SPEED_BUILD2));
			//			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_ES_TR));
			TempDiskFile.write(s);
			
			String_64 times;
			
			s.MakeMsg(_R(IDS_TIME_ENTRY),"14.4k");
			TempDiskFile.write(s);
			CalculateTime(times,14400.0);
			TempDiskFile.write(times);
			s.MakeMsg(_R(IDS_ES_TR));
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_TIME_ENTRY),"28.8k");
			TempDiskFile.write(s);
			CalculateTime(times,28800.0);
			TempDiskFile.write(times);
			s.MakeMsg(_R(IDS_ES_TR));
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_TIME_ENTRY),"33.6k");
			TempDiskFile.write(s);
			CalculateTime(times,33600.0);
			TempDiskFile.write(times);
			s.MakeMsg(_R(IDS_ES_TR));
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_TIME_ENTRY),"57.6k");
			TempDiskFile.write(s);
			CalculateTime(times,57600.0);
			TempDiskFile.write(times);
			s.MakeMsg(_R(IDS_ES_TR));
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_TIME_ENTRY),"64k");
			TempDiskFile.write(s);
			CalculateTime(times,65536.0);
			TempDiskFile.write(times);
			s.MakeMsg(_R(IDS_ES_TR));
			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_TIME_ENTRY),"128k");
			TempDiskFile.write(s);
			CalculateTime(times,131072.0);
			TempDiskFile.write(times);
			
			//			s.MakeMsg(_R(IDS_ES_TR));
			//			TempDiskFile.write(s);
			
			s.MakeMsg(_R(IDS_SPEED_END));
			TempDiskFile.write(s);
			
			TRACE( _T("m_FileSize = %d"), m_FileSize);
		} // end of if (BrowserOptions.m_bInfo != FALSE)
		
		String_64 webaddy(_R(IDS_HTML_URL_PROGRAM));
		//Mark Howitt, 29/10/97. Setup the _R(IDS_HTML_URL_VISITMSG) To be a TCHAR* Also. It likes it that way!
		String_64 webvmess(_R(IDS_HTML_URL_VISITMSG));
		
		s.MakeMsg(_R(IDS_LINK_BOX),(TCHAR *)webaddy,(TCHAR *)webvmess);
		TempDiskFile.write(s);
		
		//end of my stuff
		
		s.MakeMsg(_R(IDS_END_TABLE));
		TempDiskFile.write(s);
		
		s.MakeMsg(_R(IDS_CLOSE_CENTER));
		TempDiskFile.write(s);
		
		// output the "Exported from" string
		
		// get the xara logo file name
		String_256 Logo(_R(IDS_HTML_XARALOGO));
		
		// set it in the path
		ProgramPath.SetFileNameAndType(Logo);
		
		// get the xara link
		String_256 URL(_R(IDS_HTML_URL_XARA));
		
		// output the xara link and the xara logo
		s.MakeMsg(_R(IDS_HTML_XARA), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress());
		TempDiskFile.write(s);
		
		// Do not display the Xara X logo bottom right...
		/*
		// get the program logo file name
		Logo.Load(_R(IDS_HTML_PROGRAMLOGO));
		
		// set it in the path
		ProgramPath.SetFileNameAndType(Logo);
		
		// output the program link
		URL.Load(_R(IDS_HTML_URL_PROGRAM));
		s.MakeMsg(_R(IDS_HTML_PROGRAM), (TCHAR *)URL, (TCHAR *)ProgramPath.GetWebAddress());
		TempDiskFile.write(s);
		*/
		
		// output the end of the file
		s.Load(_R(IDS_HTML_END));
		TempDiskFile.write(s);
		
		// close the file
		TempDiskFile.close();
		
		// now export the image map, if the option for that is set
		if (BrowserOptions.m_bImagemap != FALSE)
		{
			// export the image map
			ExportImagemap( TempDiskFile, 
				m_pTempHTMLPath, 
				m_pOptions->GetSelectionType(), 
				m_pOptions->GetDPI(),
				BrowserOptions.m_ifoImagemapOptions);
		}
		
		TCHAR *FileWebAddress =  m_pTempHTMLPath->GetWebAddress();
		
		//Graham 17/9/97
		ProgramPath.SetFileNameAndType(PRODUCT_WEBLINKEXENAME);
		
		const TCHAR *PathToWebLink = (const TCHAR *)ProgramPath.GetPath();
		
		String_256 CmdLine = PathToWebLink + String_256(" -f ") + FileWebAddress;
		//TCHAR *CommandLine = (TCHAR *)CmdLine;
		
		if (!InvokeWeblink(CmdLine))
			return FALSE;
		
	} // end of TRY block
	
	catch( CFileException )
	{
		// any disk problems - come here
		
		// not much we can do really - just close the file and return FALSE
		if (TempDiskFile.isOpen())
			TempDiskFile.close();
		
		return FALSE;
	}
#endif
		
	return TRUE;
}
Exemplo n.º 16
0
/**
  * @brief  RTC Application runs in while loop
  * @param  None
  * @retval : None
  */
void RTC_Application(void)
{
  uint8_t ReturnValue;

  CalculateTime();
  
  if(TimeDateDisplay==0)
  {
    DisplayTime();
  }

  if(DisplayDateFlag==1 && TimeDateDisplay==0)
  {
    DisplayDate();
    DisplayDateFlag=0;
  }

  if(AlarmStatus==1)
  {
    DisplayAlarm();
    GPIO_SetBits(GPIOC, GPIO_Pin_6);
    Dummy=RTC_GetCounter();
    AlarmStatus=2;
  }
  if(((RTC_GetCounter()-Dummy) == 4) && (AlarmStatus==2))
  {
    GPIO_ResetBits(GPIOC, GPIO_Pin_6);
    SelIntExtOnOffConfig(ENABLE);
    RightLeftIntExtOnOffConfig(ENABLE);
    UpDownIntOnOffConfig(ENABLE);
    MenuInit();
    Dummy=0;
    AlarmStatus = 0;
  }

  if(TamperEvent == 1) /* Tamper event is detected */
  {
    TamperNumber = TamperNumber + 1;
    BKP_WriteBackupRegister(BKP_DR5,TamperNumber);
    BKP_WriteBackupRegister(BKP_DR1, CONFIGURATION_DONE);
    BKP_WriteBackupRegister(BKP_DR2,s_DateStructVar.Month);
    BKP_WriteBackupRegister(BKP_DR3,s_DateStructVar.Day);
    BKP_WriteBackupRegister(BKP_DR4,s_DateStructVar.Year);
    BKP_WriteBackupRegister(BKP_DR9,s_AlarmDateStructVar.Day);
    BKP_WriteBackupRegister(BKP_DR8,s_AlarmDateStructVar.Month);
    BKP_WriteBackupRegister(BKP_DR10,s_AlarmDateStructVar.Year);
    BKP_WriteBackupRegister(BKP_DR6,ClockSource);
    BKP_WriteBackupRegister(BKP_DR7,SummerTimeCorrect);
    ReturnValue=EE_WriteVariable(TamperNumber);
    
    if(ReturnValue==PAGE_FULL)
    {
      ReturnValue=EE_WriteVariable(TamperNumber);
    }
    
    ReturnValue=EE_WriteVariable(s_DateStructVar.Day);
    ReturnValue=EE_WriteVariable(s_DateStructVar.Month);
    ReturnValue=EE_WriteVariable((s_DateStructVar.Year)/100);
    ReturnValue=EE_WriteVariable((s_DateStructVar.Year)%100);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.HourHigh*10)+\
                    s_TimeStructVar.HourLow);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.MinHigh*10)+\
                    s_TimeStructVar.MinLow);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.SecHigh*10)+\
                    s_TimeStructVar.SecLow);
    while(!(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_13)))
    {
    }
    
    TamperEvent=0;
    BKP_TamperPinCmd(ENABLE);
  }
  
  if(BatteryRemoved != 0) /* Battery tamper is detected */
  {
    TamperNumber = TamperNumber + 1;
    BKP_WriteBackupRegister(BKP_DR5,TamperNumber);
    ReturnValue=EE_WriteVariable(TamperNumber);
    
    if(ReturnValue==PAGE_FULL)
    {
      ReturnValue=EE_WriteVariable(TamperNumber);
    }
    
    ReturnValue=EE_WriteVariable(s_DateStructVar.Day);
    ReturnValue=EE_WriteVariable(s_DateStructVar.Month);
    ReturnValue=EE_WriteVariable((s_DateStructVar.Year)/100);
    ReturnValue=EE_WriteVariable((s_DateStructVar.Year)%100);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.HourHigh*10)\
                    +s_TimeStructVar.HourLow);
    ReturnValue=EE_WriteVariable((s_TimeStructVar.MinHigh*10)\
                    +s_TimeStructVar.MinLow);
    if(BatteryRemoved==1)
    {
      ReturnValue=EE_WriteVariable(BATTERY_REMOVED);
      BatteryRemoved=0;
    }
    else if(BatteryRemoved==2)
    {
      ReturnValue=EE_WriteVariable(BATTERY_RESTORED);
      BatteryRemoved=0;
    }

    BKP_TamperPinCmd(ENABLE);
  }
}
Exemplo n.º 17
0
void Engine::Update()
{
	CalculateTime();
}