示例#1
0
char * _teto_excute_modx86(const char * code)
{
	char *_Ptr = (char *)code, *_Tmp;
	int count_function = 0;
	FUNCTION_LIST *_F_Head = 0;
	int string_len_tmp = 0;
	
	_F_Head = (FUNCTION_LIST *)malloc(sizeof(FUNCTION_LIST));

	// function MATCH
	// function\s+<functionname>\s*
	if (_Ptr = MatchLast(code, TETO_MATCH_FUNCTION))
	{
		InitFList(_F_Head);
		if (!(_Ptr = SkipWH(_Ptr)))
			;		// throw
		_Tmp = SkipIWH(_Ptr);
		string_len_tmp = _Tmp - _Ptr;
		_Ptr = _Tmp;
		//////////////////////////////////
		_Tmp = (char *)malloc(string_len_tmp + 1);
		PutText(_Ptr, _Tmp, string_len_tmp);
		_F_Head->Name = _Tmp;
		//////////////////////////////////
		_teto_excute_function_others(_Ptr, _F_Head);
	}
}
void ConsoleScreenInterface::SetCurrentDir ( char *newcurrentdir )
{

	UplinkAssert (newcurrentdir);

	char *lcdir = LowerCaseString ( newcurrentdir );

	if ( strcmp ( lcdir, "pub" ) == 0 ||
		 strcmp ( lcdir, "usr" ) == 0 ||
		 strcmp ( lcdir, "log" ) == 0 ||
		 strcmp ( lcdir, "rec" ) == 0 ||
		 strcmp ( lcdir, "sys" ) == 0 ||
		 strcmp ( lcdir, "/"   ) == 0 ) {

		UplinkStrncpy ( currentdir, lcdir, sizeof ( currentdir ) );

	} else if ( strcmp ( lcdir, "." ) == 0 ||
		strcmp ( lcdir, ".." ) == 0 ) {

		UplinkStrncpy ( currentdir, "/", sizeof ( currentdir ) );

	} else {

		PutText ( 0, "Unrecognised directory" );

	}


	delete [] lcdir;

	char newcaption [16];
	UplinkSnprintf ( newcaption, sizeof ( newcaption ), "%s:>", currentdir );
	EclRegisterCaptionChange ( "console_typehere", newcaption );

}
示例#3
0
int main()
{
    BOOL	bSuccess;
    int     i;
    char	szBuf[30];

    InitConsoleIO();        // must call this at startup

    ClrScr();              // clear the screen

    for ( i=0; i < 20; i += 2 ) {
		// QUESTION H what does the next line do?
        GotoXY(i,i);   
		// make a message and put it out
        sprintf( szBuf, "%d,%d", i, 2*i );
        bSuccess = PutText(szBuf);  // test PutText.
        if (!bSuccess) 
            printf("WriteConsoleOutputCharacter error\n"); 
    }

	// make some cool messages in different colours
    TextColour( BC_RED );
    TextBackground( BC_GREEN );
    Cprintf("Cool %d ", i++);

    TextColour( BC_BLACK );
    TextBackground( BC_LIGHTGRAY );
    Cprintf("colours %d ", i++);

    TextColour( BC_LIGHTMAGENTA );
    TextBackground( BC_BLUE );
    Cprintf(" Eh %d?", i);

    return(1);
}
示例#4
0
int main(void){
	FILE *f,*g;
	char         * buf=NULL; //书目录缓存
	
	if((f = fopen("BookInfo.txt","r")) && (g = fopen("BookIdx.txt","w"))){
		IdxListType idxlist;
		InitIdxList(idxlist);//初始化
		ElemType BookNo;

		if(!(buf=(char *)malloc(MaxLineLen*sizeof(char))))exit(OVERFLOW);

		while(!feof(f)){
			GetLine(f,buf);
			//printf("%s",buf);
			ExtractKeyWord(BookNo,buf);
			InsIdxList(idxlist,BookNo,buf);
		}

		PutText(g,idxlist);
		fclose(f);
		fclose(g);
	}else{
		printf("File open err!\n");
	}
	printf("\nResult End!\n");
	system("pause");
	return 0;
}
示例#5
0
void DrawDemo( void ) {
	char xx;
	int i;
	//char carRX = 0;
	/*u8 fontWidth;
	if ( Blink == 0 ) {
		Blink = 30000;
		fontWidth = DrawChar5x5(curX, curY, '_', LCD_PIXEL_INV);
		
		// Blink Debug LED
		GPIO_WriteReverse(GPIOD, GPIO_PIN_0);	
		
	} else {
		Blink--;
	}
	if (UART2_GetFlagStatus(UART2_FLAG_RXNE) != RESET) {
		carRX = UART2_ReceiveData8();
		
	}
	if ( carRX != 0 ) {
		fontWidth = DrawChar5x5(curX, curY, '_', LCD_PIXEL_OFF);
		if ( carRX == 13 ) {			
			curX = 2;
			curY += FONT_HEIGHT + 1;
			if ( curY > DISPLAY_HEIGHT ) {
				DrawScreen();
			}	
			
		} else if ( carRX == 10 ) {
			
		} else {			
			fontWidth = DrawChar5x5(curX, curY, carRX, LCD_PIXEL_ON);
			curX += fontWidth + 1;			
			if ( curX > DISPLAY_WIDTH ) {		
				curX = 2;
				curY += FONT_HEIGHT + 1;				
				if ( curY + FONT_HEIGHT > DISPLAY_HEIGHT ) {
					DrawScreen();
				}
			}
		}

	}*/

	Blink = 0;
	DrawScreen();
	GotoXY(2,10);
	PutText(text,LCD_PIXEL_ON);
	UpdateLCD();
	if (  strlen(text) > 0 ) {
		xx = text[0];
		for(i=1; i < strlen(text)-1; i++) {
			text[i - 1] = text[i];
		}
		text[strlen(text)-2] = xx;
	}

}
void CBDynBuffer::PutTextIndent(int Indent, LPCSTR fmt, ...)
{	
	va_list va;
	
	PutText("%*s", Indent, "");

	va_start(va, fmt);
	PutTextForm(fmt, va);
	va_end(va);
}
void ConsoleScreenInterface::AddUser ( char *name )
{

	users.PutDataAtEnd ( name );

	if ( strcmp ( name, "System" ) == 0 ) {

		PutText ( 0, "Console session started" );

	}
	else {

		char message [128];
		UplinkSnprintf ( message, sizeof ( message ), "User '%s' logged on", name );

		PutText ( 0, message );

	}

}
示例#8
0
void SaveScreen::RestoreArea(int RestoreCursor)
{
	if (ScreenBuf.empty())
		return;

	PutText(m_X1, m_Y1, m_X2, m_Y2, ScreenBuf.data());

	if (RestoreCursor)
	{
		SetCursorType(CurVisible,CurSize);
		MoveCursor(CurPosX,CurPosY);
	}
}
示例#9
0
int  Cprintf(const char *szFormat, ...)
{
    char		szBuf[300];
    va_list		arg_ptr;
    int         i;

    /* build a buffer with the message */
    va_start( arg_ptr, szFormat );
    i = vsprintf( szBuf, szFormat, arg_ptr );
    va_end( arg_ptr );
    PutText( szBuf );
    return(i);
}
示例#10
0
// CBoard 가 호출하는 그리기 함수 - 계승된 shade-box 는 이 함수를
// 오버라이드 하여 구현해야 한다
// 베이스 함수는 윈도우 전체에 가득 차는 음영을 그린다
void DStartUp::OnDraw(
	CDC* pDC,
	bool bBrushOrigin )
{
	DSB::OnDraw( pDC, bBrushOrigin );

	if ( m_nMode == 0 ) {

		PutText( pDC, _T("마이티 게임을 시작합니다 !!"), 2, 1, true,
			s_colYellow, s_tdShade );
		PutText( pDC, _T("Mighty Network Ver 4.0"), 3, 16, true,
			s_colCyan, s_tdShade );
		PutText( pDC, _T("Copyright 1999 장문성"), 3, 17, true,
			s_colCyan, s_tdShade );
		PutText( pDC, _T("2006 - 2011 UPnL"), 3, 18, true,
			s_colCyan, s_tdShade );
	}
	else {

		PutText( pDC, _T("다른 사용자와 함께 합니다"), 2, 1, true,
			s_colYellow, s_tdShade );
	}
}
示例#11
0
void Grabber::DisplayObject()
{
	MoveCursor(GArea.CurX,GArea.CurY);

	if (PrevArea.X1!=GArea.X1 || PrevArea.X2!=GArea.X2 ||
	        PrevArea.Y1!=GArea.Y1 || PrevArea.Y2!=GArea.Y2)
	{
		int X1,Y1,X2,Y2;
		X1=Min(GArea.X1,GArea.X2);
		X2=Max(GArea.X1,GArea.X2);
		Y1=Min(GArea.Y1,GArea.Y2);
		Y2=Max(GArea.Y1,GArea.Y2);

		if (X1>Min(PrevArea.X1,PrevArea.X2) || X2<Max(PrevArea.X1,PrevArea.X2) ||
		        Y1>Min(PrevArea.Y1,PrevArea.Y2) || Y2<Max(PrevArea.Y1,PrevArea.Y2))
			SaveScr->RestoreArea(FALSE);

		if (GArea.X1!=-1)
		{
			FAR_CHAR_INFO *CharBuf=new FAR_CHAR_INFO[(X2-X1+1)*(Y2-Y1+1)];
			FAR_CHAR_INFO *PrevBuf=SaveScr->GetBufferAddress();
			GetText(X1,Y1,X2,Y2,CharBuf,sizeof(FAR_CHAR_INFO)*(X2-X1+1)*(Y2-Y1+1));

			for (int X=X1; X<=X2; X++)
			{
				for (int Y=Y1; Y<=Y2; Y++)
				{
					size_t Pos=(X-X1)+(Y-Y1)*(X2-X1+1);
					const FarColor& CurColor = PrevBuf[X+Y*(ScrX+1)].Attributes;
					CharBuf[Pos].Attributes.BackgroundColor = (CurColor.Flags&FCF_BG_4BIT? ~INDEXVALUE(CurColor.BackgroundColor) : ~COLORVALUE(CurColor.BackgroundColor)) | ALPHAVALUE(CurColor.BackgroundColor);
					CharBuf[Pos].Attributes.ForegroundColor = (CurColor.Flags&FCF_FG_4BIT? ~INDEXVALUE(CurColor.ForegroundColor) : ~COLORVALUE(CurColor.ForegroundColor)) | ALPHAVALUE(CurColor.ForegroundColor);
				}
			}
			PutText(X1,Y1,X2,Y2,CharBuf);
			delete[] CharBuf;
		}

		if (GArea.X1==-2)
		{
			SaveScr->RestoreArea(FALSE);
			GArea.X1=GArea.X2;
		}

		PrevArea=GArea;
	}
}
示例#12
0
void _teto_excute_function_others(const char * _Ptr, FUNCTION_LIST *_F_Head)
{
	char *_type, *_name;
	int string_len_tmp;
	if (!(_Ptr = SkipWH(_Ptr)))
			return;		// 추가정보 없음.
	if (!skip_str(_Ptr, TETO_FUNCTION_DETAIL, 2))
			return;		// 다른용도의 공백이다.
	_Ptr += 2;
	if (!(_Ptr = SkipWH(_Ptr)))
			return;		// 추가정보 없음.
	/////////////////////////////////////////////////////
	if (skip_str(_Ptr, "get", 3))
		{
			_Ptr += 3;
			_F_Head->INJAS = (struct inja *)malloc(sizeof(struct inja));
			for (; *_Ptr == ' '; _Ptr++)
				;
			if (*_Ptr++ != '[')
				; //error
			_type = SkipIWH(_Ptr);
			string_len_tmp = _type - _Ptr;
			_Ptr = _type;
			//////////////////////////////////
			_Ptr = (char *)malloc(string_len_tmp + 1);
			PutText(_type, _Ptr, string_len_tmp);
			_F_Head->INJAS->name = _Ptr;
			//////////////////////////////////

		}
	else if (skip_str(_Ptr, "set", 3))
		;
	else if (skip_str(_Ptr, "override", 8))
		;
	else if (skip_str(_Ptr, "overload", 8))
		;
	else if (skip_str(_Ptr, "style", 5))
		;
	else if (skip_str(_Ptr, "import", 6))
		;
	else if (skip_str(_Ptr, "extend", 6))
		;
	else
		;	// 에러
}
示例#13
0
int main()
{
	char t[] = "function intkro <= get [string : t]";
	char *x;
	struct link tx, ty;
	ptr xt;
	struct _a_funciton tt;

	ty.dat = 123;
	tx.dat = &ty;
	xt = &tt;

	shift(&tx);
	x = (char *)malloc(5);
	PutText("asdf", x, 4);
	printf("%s", x);
	_teto_excute_modx86(t);
}
示例#14
0
文件: game.cpp 项目: voidproc/thunder
void Main()
{
    Window::SetTitle(L"THUNDER #Siv3DGameJam");

    // 普段の描画先:最後にSCALE倍する
    RenderTexture render_texture{ SCREEN_SIZE, Palette::Black };

    initGraphics();

    FontAsset::Register(L"title", 14, L"Times New Roman", FontStyle::BitmapBoldItalic);
    FontAsset::Register(L"sys",    6, L"Arial",       FontStyle::BitmapBold);
    FontAsset::Register(L"over",  10, L"Verdana",     FontStyle::BitmapBold);
    FontAsset::Register(L"wave",   8, L"Arial Black", FontStyle::Bitmap);
    FontAsset::Register(L"clear",  8, L"Verdana",     FontStyle::BitmapBold);

    TextureAsset::Register(L"a", L"Asset/a.png");

    gSceneMgr.add(new SceneTitle());

	while (System::Update()) {
        #ifdef _DEBUG
        // デバッグ表示
        ClearPrint();
        PutText(Profiler::FPS()).at(10, 440);
        #endif // _DEBUG

        // シーンを更新
        gSceneMgr.update();

        // シーンがなくなったらプログラム終了
        if (gSceneMgr.empty()) { break; }

        // シーンを描画
        Graphics2D::SetRenderTarget(render_texture);
        gSceneMgr.draw();

        // 拡大表示
        Graphics2D::SetRenderTarget(Graphics::GetSwapChainTexture());
        render_texture.scale(SCALE).draw();

        gSceneMgr.postUpdate();
    }
}
示例#15
0
 void main()
 {
   FILE *f; /* 任何时间最多打开一个文件 */
   IdxListType idxlist; /* 索引表 */
   int BookNo; /* 书号变量 */
   int k,l;
   f=fopen("NoIdx.txt","r"); /* 打开常用词文件 */
   if(!f)
     exit(OVERFLOW);
   fscanf(f,"%d",&noidx.last); /* 常用词个数 */
   for(k=0;k<noidx.last;k++) /* 把常用词文件的内容拷到noidx中 */
   {
     fscanf(f,"%s",buf);
     l=strlen(buf);
     noidx.item[k]=(char*)malloc(l*sizeof(char));
     strcpy(noidx.item[k],buf);
   }
   fclose(f);
   f=fopen("BookInfo.txt","r"); /* 打开书目文件 */
   if(!f)
     exit(FALSE);
   InitIdxList(&idxlist); /* 初始化索引表idxlist为空 */
   wdlist.last=0; /* 词表长度初值为0 */
   while(!feof(f))
   {
     fgets(buf,MaxLineLen,f);
     l=strlen(buf);
     if(l<=1)
       break;
     ExtractKeyWord(&BookNo); /* 从buf中提取关键词到词表,书号存入BookNo */
     InsIdxList(&idxlist,BookNo);
   }
   fclose(f);
   f=fopen("BookIdx.txt","w");
   if(!f)
     exit(INFEASIBLE);
   PutText(f,idxlist); /* 将生成的索引表idxlist输出到文件f */
   fclose(f);
 }
示例#16
0
long CreateUniverse(long loc0, char *name, long level)
{
  long loc1, loc2, lst, ptr, uni, cell, nst, reg, lat, pbd, umsh, stl, n;

  /* Check level count */

  if (level > MAX_GEOMETRY_LEVELS)
    Error(loc0, "Maximum number of geometry levels exceeded (infinite loop?)");

  /* Compare level to maximum */

  if (level + 1 > (long)RDB[DATA_GEOM_LEVELS])
    WDB[DATA_GEOM_LEVELS] = (double)(level + 1.0);

  /***************************************************************************/
 
  /***** Check if universe exists ********************************************/

  /* Loop over universes */

  uni = RDB[DATA_PTR_U0];
  while (uni > VALID_PTR)
    {
      /* Compare names */
      
      if (!strcmp(GetText(uni + UNIVERSE_PTR_NAME), name)) 
	return uni;
      
      /* Next universe */
      
      uni = NextItem(uni);
    }

  /* Create new universe */

  uni = NewItem(DATA_PTR_U0, UNIVERSE_BLOCK_SIZE);

  /* Put name */

  WDB[uni + UNIVERSE_PTR_NAME] = (double)PutText(name);

  /* Put level */
  
  WDB[uni + UNIVERSE_LEVEL] = (double)level;

  /* Reset pointers */

  WDB[uni + UNIVERSE_PTR_CELL_LIST] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_NEST] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_LAT] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_PBED] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_UMSH] = NULLPTR;
  WDB[uni + UNIVERSE_PTR_SYM] = NULLPTR;

  /* Allocate memory for collision counter */

  AllocValuePair(uni + UNIVERSE_COL_COUNT);

  /* Allocate memory for coordinates */

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PRIVA_X] = (double)ptr;

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PRIVA_Y] = (double)ptr;

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PRIVA_Z] = (double)ptr;

  /* Onko tän ajan pakko olla universe-rakenteessa? */

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PRIVA_T] = (double)ptr;

  /* Allocate memory for previous region */

  ptr = AllocPrivateData(1, PRIVA_ARRAY);
  WDB[uni + UNIVERSE_PTR_PREV_REG] = (double)ptr;

  /***************************************************************************/

  /***** Cells ***************************************************************/

  /* Loop over cells */

  cell = RDB[DATA_PTR_C0];
  while (cell > VALID_PTR)
    {

      /* Compare names and check used-flag */

      if (!((long)RDB[cell + CELL_OPTIONS] & OPT_USED))
	if (CompareStr(cell + CELL_PTR_UNI, uni + UNIVERSE_PTR_NAME))
	  {
	    /* Set used-flag */

	    SetOption(cell + CELL_OPTIONS, OPT_USED);

	    /* Put pointer */
	    
	    WDB[cell + CELL_PTR_UNI] = (double)uni;
	    
	    /* Create new item in universe cell list */
	    
	    lst = NewItem(uni + UNIVERSE_PTR_CELL_LIST, CELL_LIST_BLOCK_SIZE);
	    
	    /* Put pointer */
	    
	    WDB[lst + CELL_LIST_PTR_CELL] = (double)cell;

	    /* Allocate memory from private array */

	    ptr = AllocPrivateData(1, PRIVA_ARRAY);

	    /* Put pointer */
	    
	    WDB[lst + CELL_LIST_PTR_COUNT] = (double)ptr;

	    /* Check if fill pointer is set */
	    
	    if (RDB[cell + CELL_PTR_FILL] > VALID_PTR)
	      {
		/* Call recursively */
		
		sprintf(name, "%s", GetText(cell + CELL_PTR_FILL));
		loc1 = CreateUniverse(cell, name, level + 1);
		
		/* Put pointer */
		
		WDB[cell + CELL_PTR_FILL] = (double)loc1;
	      }
	    
	    /* Put universe type */
	    
	    WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_CELL;
	  }
      
      /* Next cell */
      
      cell = NextItem(cell);
    }

  /* Check if cells are defined */
  
  if ((ptr = (long)RDB[uni + UNIVERSE_PTR_CELL_LIST]) > 0)
    {
      /* Close list (NOTE: Tää oli processinput.c:ssä 8.11.2010 asti) */

      CloseList(ptr);

      /* Return pointer to universe */

      return uni;
    }

  /***************************************************************************/

  /***** Nests ***************************************************************/

  /* Loop over nests */

  nst = RDB[DATA_PTR_NST0];
  while (nst > VALID_PTR)
    {
      /* Compare names and check used-flag */
      
      if ((CompareStr(nst + NEST_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[nst + NEST_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(nst + NEST_OPTIONS, OPT_USED);

	  /* Put pointers */
	  
	  WDB[nst + NEST_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_NEST] = (double)nst;

	  /* Get pointer to regions */
	      
	  reg = (long)RDB[nst + NEST_PTR_REGIONS];
	  CheckPointer(FUNCTION_NAME, "(reg)", DATA_ARRAY, reg);

	  /* Close list */

	  CloseList(reg);

	  /* Loop over regions */ 
	      
	  while (reg > VALID_PTR)
	    {
	      /* Check if fill pointer is set */

	      if (RDB[reg + NEST_REG_PTR_FILL] > VALID_PTR)
		{
		  /* Call recursively */

		  sprintf(name, "%s", GetText(reg + NEST_REG_PTR_FILL));
		  loc1 = CreateUniverse(nst, name, level + 1);

		  /* Put pointer */

		  WDB[reg + NEST_REG_PTR_FILL] = (double)loc1;
		}

	      /* Next region */

	      reg = NextItem(reg);
	    }

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_NEST;

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next nest */

      nst = NextItem(nst);
    }

  /***************************************************************************/

  /***** Lattices ************************************************************/

  /* Loop over lattices */

  lat = RDB[DATA_PTR_L0];
  while (lat > VALID_PTR)
    {
      /* Compare names and check used-flag */

      if ((CompareStr(lat + LAT_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[lat + LAT_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(lat + LAT_OPTIONS, OPT_USED);

	  /* Put pointers */

	  WDB[lat + LAT_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_LAT] = (double)lat;

	  /* Check type */

	  if ((long)RDB[lat + LAT_TYPE] == LAT_TYPE_CLU)
	    {
	      /***** Circular array ******************************************/
	      
	      /* Get pointer to rings */
	      
	      reg = (long)RDB[lat + LAT_PTR_FILL];
	      CheckPointer(FUNCTION_NAME, "(reg)", DATA_ARRAY, reg);

	      /* Loop over rings */ 
	      
	      while (reg > VALID_PTR)
		{
		  /* Loop over items */ 
		  
		  ptr = (long)RDB[reg + RING_PTR_FILL];
		  while ((long)RDB[ptr] > VALID_PTR)
		    {
		      /* Call recursively */
		      
		      sprintf(name, "%s", GetText(ptr));
		      loc1 = CreateUniverse(lat, name, level + 1);
		      
		      /* Put pointer */
		      
		      WDB[ptr++] = (double)loc1;
		    }

		  /* Next region */

		  reg = NextItem(reg);
		}

	      /***************************************************************/
	    }
	  else
	    {
	      /***** Simple types ********************************************/
	      
	      /* Loop over items */ 
	  
	      ptr = (long)RDB[lat + LAT_PTR_FILL];
	      while ((long)RDB[ptr] > VALID_PTR)
		{
		  /* Get universe  name */

		  sprintf(name, "%s", GetText(ptr));

		  /* Check if intentionally undefined (dots) */

		  for (n = 0; n < strlen(name); n++)
		    if (name[n] != '.')
		      break;
		  
		  /* Call recursively or put null pointer */
		  
		  if (n < strlen(name))
		    loc1 = CreateUniverse(lat, name, level + 1);
		  else
		    loc1 = NULLPTR;
		    
		  /* Put pointer */
		  
		  WDB[ptr++] = (double)loc1;
		}

	      /***************************************************************/
	    }

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_LATTICE;

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next lattice */

      lat = NextItem(lat);
    }

  /***************************************************************************/

  /***** Pebble-bed geometries ***********************************************/

  /* Loop over geometries */

  pbd = RDB[DATA_PTR_PB0];
  while (pbd > VALID_PTR)
    {
      /* Compare names and check used-flag */
      
      if ((CompareStr(pbd + PBED_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[pbd + PBED_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(pbd + PBED_OPTIONS, OPT_USED);

	  /* Put pointers */

	  WDB[pbd + PBED_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_PBED] = (double)pbd;

	  /* Call recursively for background universe */
	  
	  sprintf(name, "%s", GetText(pbd + PBED_PTR_BG_UNIV));
	  loc1 = CreateUniverse(pbd, name, level + 1);

	  /* Put pointer */

	  WDB[pbd + PBED_PTR_BG_UNIV] = (double)loc1;

	  /* Loop over pebbles */
	  
	  loc1 = (long)RDB[pbd + PBED_PTR_PEBBLES];
	  while (loc1 > VALID_PTR)
	    {
	      /* Call recursively for pebble */
	  
	      sprintf(name, "%s", GetText(loc1 + PEBBLE_PTR_UNIV));
	      ptr = CreateUniverse(pbd, name, level + 1);

	      /* Put pointer */

	      WDB[loc1 + PEBBLE_PTR_UNIV] = (double)ptr;

	      /* Loop over types */

	      loc2 = (long)RDB[pbd + PBED_PTR_PEBBLE_TYPES];
	      while(loc2 > VALID_PTR)
		{
		  /* Compare universe pointer */

		  if ((long)RDB[loc2 + PEBTYPE_PTR_UNIV] == ptr)
		    {
		      /* Add counter */

		      WDB[loc2 + PEBTYPE_COUNT] = 
			RDB[loc2 + PEBTYPE_COUNT] + 1.0;

		      /* Break loop */

		      break;
		    }

		  /* Next type */

		  loc2 = NextItem(loc2);
		}

	      /* Check pointer */

	      if (loc2 < VALID_PTR)
		{
		  /* No previous definition */

		  loc2 = NewItem(pbd + PBED_PTR_PEBBLE_TYPES, 
				 PEBTYPE_BLOCK_SIZE);

		  /* Put universe pointer */

		  WDB[loc2 + PEBTYPE_PTR_UNIV] = (double)ptr;

		  /* Init counter */

		  WDB[loc2 + PEBTYPE_COUNT] = 1.0;
		}

	      /* Next pebble */

	      loc1 = NextItem(loc1);
	    }

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_PBED;

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next geometry */

      pbd = NextItem(pbd);
    }

  /***************************************************************************/

  /***** Unstructured mesh based geometries **********************************/

  /* Loop over geometries */

  umsh = RDB[DATA_PTR_UMSH0];
  while (umsh > VALID_PTR)
    {
      /* Compare names and check used-flag */
      
      if ((CompareStr(umsh + UMSH_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[umsh + UMSH_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(umsh + UMSH_OPTIONS, OPT_USED);

	  /* Put pointers */

	  WDB[umsh + UMSH_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_UMSH] = (double)umsh;

	  /* Call recursively for background universe */
	  
	  sprintf(name, "%s", GetText(umsh + UMSH_PTR_BG_UNIV));
	  loc1 = CreateUniverse(umsh, name, level + 1);

	  /* Put pointer */

	  WDB[umsh + UMSH_PTR_BG_UNIV] = (double)loc1;

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_UMSH;

	  /* Allocate memory for next cell */

	  AllocValuePair(uni + UNIVERSE_PTR_NEXT_CELL);

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next geometry */

      umsh = NextItem(umsh);
    }

  /***************************************************************************/

  /***** STL geometries ******************************************************/

  /* Loop over geometries */
 
  stl = RDB[DATA_PTR_STL0];
  while (stl > VALID_PTR)
    {
      /* Compare names and check used-flag */
      
      if ((CompareStr(stl + STL_PTR_NAME, uni + UNIVERSE_PTR_NAME)) &
	  !((long)RDB[stl + STL_OPTIONS] & OPT_USED))
	{
	  /* Set used-flag */

	  SetOption(stl + STL_OPTIONS, OPT_USED);

	  /* Put pointers */

	  WDB[stl + STL_PTR_UNI] = (double)uni;
	  WDB[uni + UNIVERSE_PTR_STL] = (double)stl;

	  /* Call recursively for background universe */
	  
	  sprintf(name, "%s", GetText(stl + STL_PTR_BG_UNIV));
	  loc1 = CreateUniverse(stl, name, level + 1);

	  /* Put pointer */

	  WDB[stl + STL_PTR_BG_UNIV] = (double)loc1;

	  /* Put universe type */

	  WDB[uni + UNIVERSE_TYPE] = (double)UNIVERSE_TYPE_STL;

	  /* Return pointer to universe */

	  return uni;
	}

      /* Next geometry */

      stl = NextItem(stl);
    }

  /***************************************************************************/

  /* Universe is not defined */
  
  if ((level == 0) && ((long)RDB[DATA_PTR_ROOT_UNIVERSE] < VALID_PTR))
    Error(loc0, "Root universe %s is not defined", name);
  else
    Error(loc0, "Universe %s is not defined", name);
  
  /* Avoid compiler warning */

  return NULLPTR;
}
示例#17
0
void DrawGPSData( void ) {
	int tmp,barrapos,sinal,x,y;
	u8 str_buffer[0x10];
	float valor;
	gps_data_t local_gps_data;
	
	
	get_gps_data(&local_gps_data);
	
	valor = local_gps_data.pos.lat;
	sprintf(str_buffer, "%03.6f", valor);
	GotoXY( 0, 0 );
	PutText("LAT : ", LCD_PIXEL_ON);
	PutText(str_buffer, LCD_PIXEL_ON);

	valor = local_gps_data.pos.lon;
	sprintf(str_buffer, "%03.6f", valor);	
	GotoXY( 0, 6 );
	PutText("LON : ", LCD_PIXEL_ON);
	PutText(str_buffer, LCD_PIXEL_ON);
	
	valor = local_gps_data.pos.alt;
	sprintf(str_buffer, "%04.1f", valor);	
	GotoXY( 0, 12 );
	PutText("ALT : ", LCD_PIXEL_ON);
	PutText(str_buffer, LCD_PIXEL_ON);
	/*
	valor = local_gps_data.status.siu;
	sprintf(str_buffer, "%d", (int)valor);	
	GotoXY( 70, 0 );
	PutText("SAT : ", LCD_PIXEL_ON);
	PutText(str_buffer, LCD_PIXEL_ON);
	
	valor = local_gps_data.pos.cor;
	sprintf(str_buffer, "%d", (int)valor);	
	GotoXY( 70, 6 );
	PutText("CUR : ", LCD_PIXEL_ON);
	PutText(str_buffer, LCD_PIXEL_ON);
	
	valor = local_gps_data.pos.spd;
	sprintf(str_buffer, "%d", (int)valor);	
	GotoXY( 70, 12 );
	PutText("SPE : ", LCD_PIXEL_ON);
	PutText(str_buffer, LCD_PIXEL_ON);
	*/
	
	GotoXY( 0, 51 );	
	PutText(local_gps_data.datetime.date, LCD_PIXEL_ON);
	PutText("   ", LCD_PIXEL_ON);
	PutText(local_gps_data.datetime.time, LCD_PIXEL_ON);	
	
	DrawCircle( 95,30,30, LCD_PIXEL_ON );
	DrawCircle( 95,30,20, LCD_PIXEL_ON );
	DrawCircle( 95,30,10, LCD_PIXEL_ON );
	DrawCircle( 95,30,1, LCD_PIXEL_ON );
	barrapos = 2;
	for(tmp = 0; tmp < 12; tmp++) {
		valor = local_gps_data.sat_inview[tmp].snr;		
		sinal = (int)valor / 5;
		DrawRectangle( barrapos - 1,27, barrapos + 1, 49, LCD_PIXEL_ON);
		DrawFillRectangle( barrapos - 1,49 - sinal, barrapos + 1, 49, LCD_PIXEL_ON); 
		barrapos += 5;
		if ( valor > 0) {
			x = 95 + (30 - local_gps_data.sat_inview[tmp].ele / 3 ) * cos(local_gps_data.sat_inview[tmp].azi);
			y = 30 + (30 - local_gps_data.sat_inview[tmp].ele / 3 ) * sin(local_gps_data.sat_inview[tmp].azi);
			DrawCircle( x,y,3, LCD_PIXEL_ON );
			DrawCircle( x,y,2, LCD_PIXEL_ON );
			DrawCircle( x,y,1, LCD_PIXEL_ON );
			DrawPoint( x,y, LCD_PIXEL_ON );
			GotoXY( x - 1, y - 2 );
			sprintf(str_buffer, "%01d", (int)tmp);
			PutText(str_buffer, LCD_PIXEL_OFF);
		}
	}
	
}
示例#18
0
void ReadMaterialComp()
{
  char *input, fname[MAX_STR], word[MAX_STR], pname[MAX_STR], **params;
  long loc0, loc1, mat, mat0, iso, iso0, nuc, i0, i, np, j, n, line, r, g, b;
  double val, sum;
  FILE *fp;

  /* Get pointer to file list */

  if ((loc0 = (long)RDB[DATA_PTR_COMP_FILE]) < VALID_PTR)
    return;

  fprintf(out, "Overriding initial material compositions...\n");

  /* Reset previous pointer */

  mat0 = -1;

  /* Reset counters for line number calculation */

  WDB[DATA_LINE_NUM_N0] = 0.0;
  WDB[DATA_LINE_NUM_NL0] = 1.0;

  /* Loop over list */

  while (RDB[loc0] > VALID_PTR)
    {
      /* Get file name */

      sprintf(fname, "%s", GetText(loc0));

      /* Check that file exists */

      if ((fp = fopen(fname, "r")) != NULL)
	fclose(fp);
      else
	{
	  /* File not found */
	  
	  Error(0, "Material composition file \"%s\" does not exist", fname);
	}

      /* Read input file */
  
      input = ReadTextFile(fname);

      /* Avoid compiler warning */
      
      params = NULL;

      /* Loop over file */
      
      i0 = 0;
      while ((i = NextWord(&input[i0], word)) > 0)
	{
	  /* update pointer */
	  
	  i0 = i0 + i;

	  /* Get line number for error messages */
	  
	  line = GetLineNumber(input, i0);

	  /* Look for material definition */

	  if (!strcasecmp(word, "mat"))
	    {
	      /* Copy parameter name */

	      strcpy (pname, word);

	      /* Read parameters */

	      params = GetParams(word, input, &np, &i0, 4, 4*MAX_ISOTOPES + 8, 
				 fname);

	      /* Read data */

	      j = 0;

	      /* Find material (try starting from previous) */

	      mat = mat0;
	      while (mat > VALID_PTR)
		{
		  /* Compare */

		  if (!strcmp(params[j], GetText(mat + MATERIAL_PTR_NAME)))
		    break;

		  /* Next */

		  mat = NextItem(mat);
		}

	      /* Find material (start from beginning) */

	      if (mat < VALID_PTR)
		{
		  mat = (long)RDB[DATA_PTR_M0];
		  while (mat > VALID_PTR)
		    {
		      /* Compare */
		      
		      if (!strcmp(params[j], GetText(mat + MATERIAL_PTR_NAME)))
			break;
		      
		      /* Next */
		      
		      mat = NextItem(mat);
		    }
		}

	      /* Check */

	      if (mat < VALID_PTR)
		Error(-1, pname, fname, line, "Material %s is not defined",
		      params[j]);
	      else
		j++;

	      /* Remember previous */

	      mat0 = NextItem(mat);
	      
	      /* Material density */

	      if (!strcmp(params[j], "sum"))
		{
		  /* Set value to -inf to calculate sum from composition */
		  
		  WDB[mat + MATERIAL_ADENS] = -INFTY;
		  
		  j++;
		}
	      else
		{
		  /* Read value */
		  
		  WDB[mat + MATERIAL_ADENS] = 
		    TestParam(pname, fname, line, params[j++], PTYPE_REAL,
			      -1000.0, 1000.0);
		}

	      /* Reset sum */

	      sum = 0.0;

	      /* Reset previous pointer */

	      iso0 = -1;

	      /* Loop over parameters */
	  
	      while (j < np)
		{
		  /* Check parameter */
		  
		  if (!strcmp(params[j], "tmp"))
		    {
		      /***** Temperature for Doppler-breadening **************/
		  
		      j++;
		      
		      /* Get temperature */
		      
		      WDB[mat + MATERIAL_DOPPLER_TEMP] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);

		      /* Set option */
		      
		      WDB[DATA_USE_DOPPLER_PREPROCESSOR] = (double)YES;
		      
		      /*******************************************************/
		    }
		  if (!strcmp(params[j], "tms") || !strcmp(params[j], "ettm"))
		    {
		      /***** Temperature for TMS *****************************/
		  
		      j++;
		      
		      /* Get temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMIN] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);
		      
		      /* Copy to maximum */
		      
		      WDB[mat + MATERIAL_TMS_TMAX] = 
			RDB[mat + MATERIAL_TMS_TMIN];
		      
		      /* Set mode */
		      
		      WDB[DATA_TMS_MODE] = (double)TMS_MODE_CE;
		      WDB[mat + MATERIAL_TMS_MODE] = (double)YES;
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "rgb"))
		    {
		      /***** Material colour *********************************/

		      j++;
		      
		      /* Get r, b and g */
		      
		      r = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);
		      
		      g = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);

		      b = TestParam(pname, fname, line, params[j++], 
				    PTYPE_INT, 0, 255);

		      /* Set color */
		      
		      WDB[mat + MATERIAL_RGB] = b + 1000.0*g + 1000000.0*r;
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "vol"))
		    {
		      /***** Material volume *********************************/
		      
		      j++;
		      
		      /* Get volume */
		      
		      WDB[mat + MATERIAL_VOLUME_GIVEN] =
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "fix"))
		    {
		      /***** Default library ID and temperature***************/

		      j++;
		  
		      /* Get default ID and temperature */
		      
		      WDB[mat + MATERIAL_DEFAULT_PTR_LIB_ID] = 
			PutText(params[j++]);
		      WDB[mat + MATERIAL_DEFAULT_TMP] = 
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "mass"))
		    {
		      /***** Material mass ***********************************/

		      j++;
		      
		      /* Get mass */
		      
		      WDB[mat + MATERIAL_MASS_GIVEN] = 
			TestParam(pname, fname, line, params[j++], PTYPE_REAL, 
				  0.0, INFTY);

		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "burn"))
		    {
		      /***** Burnable material *******************************/
		      
		      j++;
		      
		      /* Set burn flag */
		      
		      SetOption(mat + MATERIAL_OPTIONS, OPT_BURN_MAT);
		      
		      /* Set burn sort flag and materials flag */
		      
		      WDB[mat + MATERIAL_BURN_SORT_FLAG] = 1.0;
		      WDB[DATA_BURN_MATERIALS_FLAG] = (double)YES;
		      
		      /* Get number of rings */
		      
		      WDB[mat + MATERIAL_BURN_RINGS] = 
			(double)TestParam(pname, fname, line, params[j++], 
					  PTYPE_INT, 0, 10000000);
		  
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "moder"))
		    {
		      /***** Thermal scattering data *************************/

		      j++;
		      
		      /* Check number of parameters */
		      
		      if (j > np - 3)
			Error(mat, "Invalid number of parameters");
		      
		      /* Create new item (use the same structure as with */
		      /* the therm card) */
		      
		      WDB[mat + MATERIAL_PTR_SAB] = NULLPTR;
		      loc1 = NewItem(mat + MATERIAL_PTR_SAB, 
				     THERM_BLOCK_SIZE);

		      /* Read name */
		      
		      WDB[loc1 + THERM_PTR_ALIAS] = 
			(double)PutText(params[j++]);
		      
		      /* Read ZA */
		      
		      WDB[loc1 + THERM_ZA] =  
			(double)TestParam(pname, fname, line, params[j++], 
					  PTYPE_INT, 1001, 120000);
		      
		      /*******************************************************/
		    }
		  else if (!strcmp(params[j], "tft"))
		    {
		      /***** Minimum and maximum temperatures for TMS ********/

		      j++;
		      
		      /* Get minimum temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMIN] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, 0.0, 100000.0);
		      
		      /* Get maximum temperature */
		      
		      WDB[mat + MATERIAL_TMS_TMAX] = 
			TestParam(pname, fname, line, params[j++], 
				  PTYPE_REAL, RDB[mat + MATERIAL_TMS_TMIN],
				  100000.0);
		      
		      /* Set mode */
		      
		      WDB[DATA_TMS_MODE] = (double)TMS_MODE_CE;
		      WDB[mat + MATERIAL_TMS_MODE] = (double)YES;
		      
		      /*******************************************************/
		    }
		  else 
		    {
		      /***** Composition *************************************/

		      /* Find nuclide in composition (start from previous) */

		      iso = iso0;
		      while (iso > VALID_PTR)
			{
			  /* Pointer to nuclide data */

			  nuc = (long)RDB[iso + COMPOSITION_PTR_NUCLIDE];
			  CheckPointer(FUNCTION_NAME, "(nuc)", DATA_ARRAY,nuc);

			  /* Compare */
			  
			  if (!strcmp(GetText(nuc + NUCLIDE_PTR_NAME),
				      params[j]))
			    break;

			  /* Next */

			  iso = NextItem(iso);
			}

		      /* Find nuclide in composition (start from beginning) */

		      if (iso < VALID_PTR)
			{			  
			  iso = (long)RDB[mat + MATERIAL_PTR_COMP];
			  while (iso > VALID_PTR)
			    {
			      /* Pointer to nuclide data */
			      
			      nuc = (long)RDB[iso + COMPOSITION_PTR_NUCLIDE];
			      CheckPointer(FUNCTION_NAME, "(nuc)", 
					   DATA_ARRAY,nuc);

			      /* Compare */
			  
			      if (!strcmp(GetText(nuc + NUCLIDE_PTR_NAME),
					  params[j]))
				break;
			      
			      /* Next */
			      
			      iso = NextItem(iso);
			    }
			}

		      /* Check pointer */
		      
		      if (iso < VALID_PTR)
			Error(-1, pname, fname, line, 
			      "Material %s has no nuclide %s in composition",
			      GetText(mat + MATERIAL_PTR_NAME), params[j]);
		      else
			j++;

		      /* Remember pointer */

		      iso0 = iso;
			      
		      /* Read fraction */
		  
		      val = TestParam(pname, fname, line, params[j++], 
				      PTYPE_REAL, -100.0, 1E+25);
		  
		      /* Put value */

		      WDB[iso + COMPOSITION_ADENS] = val;

		      /* Add to sum */
		      
		      sum = sum + val;
		      
		      /*******************************************************/
		    }
		}
	      
	      /* Set density if sum */

	      if (RDB[mat + MATERIAL_ADENS] == -INFTY)
		WDB[mat + MATERIAL_ADENS] = sum;

	      /* Calculate normalized fractions */
	      
	      IsotopeFractions(mat);
  	    }

	  /* Free parameter list */
      
	  if (np > 0)
	    for (n = 0; n < np + 1; n++)
	      Mem(MEM_FREE, params[n]);
	}

      /* Free memory */
  
      Mem(MEM_FREE, input);

      /* Next file */

      loc0++;
    }

  /* This must be called to get the divided compositions into material */
  /* structures */

  SumDivCompositions();
  
  fprintf(out, "OK.\n\n");
}
bool FreeTypeTextPrinter::PutText(cv::Mat& img, const std::wstring& string, cv::Point begin_point)
{
	return PutText(img, string, begin_point, begin_point);
}