コード例 #1
0
ファイル: m_sqlite3.cpp プロジェクト: bandicot/inspircd
	void init()
	{
		ReadConf();

		Implementation eventlist[] = { I_OnRehash };
		ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
	}
コード例 #2
0
ファイル: m_sqlite3.cpp プロジェクト: thepaul/inspircd-deb
	ModuleSQLite3(InspIRCd* Me)
	: Module(Me), currid(0)
	{
		ServerInstance->Modules->UseInterface("SQLutils");

		if (!ServerInstance->Modules->PublishFeature("SQL", this))
		{
			throw ModuleException("m_sqlite3: Unable to publish feature 'SQL'");
		}

		/* Create a socket on a random port. Let the tcp stack allocate us an available port */
#ifdef IPV6
		listener = new SQLiteListener(this, ServerInstance, 0, "::1");
#else
		listener = new SQLiteListener(this, ServerInstance, 0, "127.0.0.1");
#endif

		if (listener->GetFd() == -1)
		{
			ServerInstance->Modules->DoneWithInterface("SQLutils");
			throw ModuleException("m_sqlite3: unable to create ITC pipe");
		}
		else
		{
			ServerInstance->Logs->Log("m_sqlite3", DEBUG, "SQLite: Interthread comms port is %d", listener->GetPort());
		}

		ReadConf();

		ServerInstance->Modules->PublishInterface("SQL", this);
		Implementation eventlist[] = { I_OnRequest, I_OnRehash };
		ServerInstance->Modules->Attach(eventlist, this, 2);
	}
コード例 #3
0
ファイル: genwrapper.cpp プロジェクト: tell/pbkz
    void initialize() {
        if (init>0) return; 
#ifdef _allow_cachefiles
        cachedir =  makefullpath(ReadConf("bkz.conf","svpccache"));
        mkdirRecursive(cachedir.c_str(), 0777);
#endif       
        init  = 1;
    }
コード例 #4
0
ファイル: server.cpp プロジェクト: Seikareikou/symbian
void CMyServer::ConstructL()
    {
    __LOGSTR("Construct");
    CActiveScheduler::Add(this);
    iWs = RWsSession();
    iFs.Connect();

    iTextPlain = CPlainText::NewL();

    ReadConf();
    __LOGSTR("ReadConfComplete");
	iOldName = _L("ClipboardChanged");

    iWs.Connect(iFs);
    iTaskList = new(ELeave) TApaTaskList(iWs);

    iScreen = new(ELeave) CWsScreenDevice(iWs);
    CleanupStack::PushL(iScreen);
    iScreen->Construct();
    CleanupStack::Pop(iScreen);

    iChangeTrap = CChangeTrap::NewL();
    iChangeTrap->SetObserver(this);
    iTimer = CPTimer::NewL();
    iTimer->SetObserver(this);
    iCaller = CCaller::NewL();

    iWg = RWindowGroup(iWs);
    iWg.Construct((TUint32)&iWg,EFalse);
    iWg.SetOrdinalPosition(0,ECoeWinPriorityAlwaysAtFront);
    iWg.EnableReceiptOfFocus(EFalse);
    iScreen->CreateContext(iGc);
    iWindow = RWindow(iWs);
    iWindow.Construct(iWg,(TUint32)&iWg+1);

    iWindow.Activate();
    iWindow.SetExtent(TPoint(0,0),TSize(1,1));
    iWindow.SetRequiredDisplayMode(EColor16MA);
	iWindow.SetOrdinalPosition(5555,ECoeWinPriorityAlwaysAtFront);
    TRgb backgroundColour = KRgbBlack;
    //if(KErrNone == iWindow.SetTransparencyAlphaChannel())
   // 	{
    //	backgroundColour.SetAlpha(0);
    //	}
    iWindow.SetBackgroundColor(backgroundColour);


    GetFontSize();

    iWindow.SetSize(iSize);
    __LOGSTR2("iSize1: %d,iSize2: %d",iSize.iWidth,iSize.iHeight);
    iPos=TPoint(iConfig.iX,iConfig.iY);
	iWindow.SetVisible(EFalse);


    iWs.Flush();
    //Draw(iOldName);
    }
コード例 #5
0
ファイル: updatedlg.cpp プロジェクト: DowerChest/codeblocks
void UpdateDlg::InternetUpdate(bool forceDownload)
{
    UpdateStatus(_("Please wait..."));
    m_HasUpdated = false;
    m_Net.SetServer(GetCurrentServer());

    EnableButtons(false);
    forceDownload = forceDownload || !XRCCTRL(*this, "chkCache", wxCheckBox)->GetValue();

    bool forceDownloadMirrors = forceDownload || !wxFileExists(GetMirrorsFilename());
    if (forceDownloadMirrors)
    {
        if (!m_Net.DownloadFile(_T("mirrors.cfg"), GetMirrorsFilename()))
        {
            UpdateStatus(_("Error downloading list of mirrors"), 0, 0);
            return;
        }
        else
        {
            FillServers();
            m_Net.SetServer(GetCurrentServer()); // update server based on mirrors
        }
    }

    wxString config = GetConfFilename();
    forceDownload = forceDownload || !wxFileExists(config);
    if (forceDownload && !m_Net.DownloadFile(_T("webupdate.conf"), config))
    {
        UpdateStatus(_("Error downloading list of updates"), 0, 0);
        return;
    }
    else
    {
        IniParser ini;
        if (!ini.ParseFile(config))
        {
            UpdateStatus(_("Failed to retrieve the list of updates"), 0, 0);
            return;
        }
        ini.Sort();

        if (m_Recs)
            delete[] m_Recs;

        // remember to delete[] m_Recs when we 're done with it!!!
        // it's our responsibility once given to us
        m_Recs = ReadConf(ini, &m_RecsCount, GetCurrentServer(), GetPackagePath());

        FillGroups();
    }
    EnableButtons();
    UpdateStatus(_("Ready"), 0, 0);

    m_HasUpdated = true;
}
コード例 #6
0
ファイル: win.cpp プロジェクト: nekocode/FScript0.2
INT WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE, LPWSTR, INT )
{
	hinst = hInstance;			//将实例句柄存储在全局变量中
	
	MyRegisterClass(hInstance);	//注册窗口类
	ReadConf();					//读取配置文件

	//创建并显示主窗口
	if (MyShowWindow(hInstance, SW_SHOWDEFAULT))
	{
		Init();

		ShowCursor(false);
#ifndef _DEBUG
		//创建脚本处理线程
		boost::thread Thread_Script_Process(Script_Process);
#endif

		//主消息循环:
		MSG msg;
		ZeroMemory(&msg,sizeof(msg));
		while(msg.message != WM_QUIT)
		{
			if(PeekMessage(&msg,NULL,0U,0U,PM_REMOVE))
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			else
				gameRender();
		}

		//传递线程退出消息给ScriptThread
		ScriptThreadExit = true;
		ReleaseMusicModule();

#ifndef _DEBUG
		//等待脚本处理线程结束
		Thread_Script_Process.join();
#endif

		//释放dx渲染库
		ReleaseDxDrawDLL();
	}

	UnregisterClass(szWindowClass,hinst);
	return 0;
}
コード例 #7
0
ファイル: m_pgsql.cpp プロジェクト: thepaul/inspircd-deb
	ModulePgSQL(InspIRCd* Me)
	: Module(Me), currid(0)
	{
		ServerInstance->Modules->UseInterface("SQLutils");

		sqlsuccess = new char[strlen(SQLSUCCESS)+1];

		strlcpy(sqlsuccess, SQLSUCCESS, strlen(SQLSUCCESS));

		if (!ServerInstance->Modules->PublishFeature("SQL", this))
		{
			throw ModuleException("BUG: PgSQL Unable to publish feature 'SQL'");
		}

		ReadConf();

		ServerInstance->Modules->PublishInterface("SQL", this);
		Implementation eventlist[] = { I_OnUnloadModule, I_OnRequest, I_OnRehash };
		ServerInstance->Modules->Attach(eventlist, this, 3);
	}
コード例 #8
0
ファイル: ssaver.c プロジェクト: OpenDMM/tuxbox-apps
int main (int argc, char **argv)
{
	int tv,index,i,j,cmct=CMCT,cmc=CMC,trnspi=TRANSP,trnsp=0,found,loop=1,first=1,x0,x1,x2,x3,x4,x5,x6,x7;
	int xdir=1, ydir=1;
	double xstep=1, ystep=1; 
	double csx, cex, csy, cey;
	time_t atim;
	struct tm *ltim;
	char *aptr,*rptr;
	char dstr[2]={0,0};

		printf("SSaver Version %s\n",CL_VERSION);
		
		ReadConf();
	
		for(i=1; i<argc; i++)
		{
			aptr=argv[i];
			if((rptr=strchr(aptr,'='))!=NULL)
			{
				rptr++;
				if(strstr(aptr,"DATE=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						sdat=j;
					}
				}
				if(strstr(aptr,"BIG=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						big=(j)?1:0;
					}
				}
				if(strstr(aptr,"SEC=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						secs=j;
					}
				}
				if(strstr(aptr,"SLOW=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						if(!j)
						{
							j=1;
						}
						slow=j;
					}
				}
				if(strstr(aptr,"FCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						fcol=j;
					}
				}
				if(strstr(aptr,"BCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						bcol=j;
					}
				}
			}
		}
		if((sx=Read_Neutrino_Cfg("screen_StartX"))<0)
			sx=80;
		
		if((ex=Read_Neutrino_Cfg("screen_EndX"))<0)
			ex=620;

		if((sy=Read_Neutrino_Cfg("screen_StartY"))<0)
			sy=80;

		if((ey=Read_Neutrino_Cfg("screen_EndY"))<0)
			ey=505;
		
		if(!slow)
		{
			slow=1;
		}	
		if(slow>10)
		{
			slow=10;
		}
		
		xpos=ex/2;
		ypos=ey/2;	
		for(index=CMCST; index<=CMH; index++)
		{
			sprintf(tstr,"menu_%s_alpha",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				tr[index-1]=(tv<<8);

			sprintf(tstr,"menu_%s_blue",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				bl[index-1]=(tv+(tv<<8));

			sprintf(tstr,"menu_%s_green",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				gn[index-1]=(tv+(tv<<8));

			sprintf(tstr,"menu_%s_red",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				rd[index-1]=(tv+(tv<<8));
		}
		
		fb = open(FB_DEVICE, O_RDWR);

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("Clock <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("Clock <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		
		if(ioctl(fb, FBIOGETCMAP, &colormap) == -1)
		{
			printf("Clock <FBIOGETCMAP failed>\n");
			return -1;
		}

		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("Clock <mapping of Framebuffer failed>\n");
			return -1;
		}

	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("Clock <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("Clock <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("Clock <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
		{
			printf("Clock <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		use_kerning = FT_HAS_KERNING(face);

#ifdef FT_NEW_CACHE_API
		desc.face_id = FONT;
		desc.flags = FT_LOAD_MONOCHROME;
#else
		desc.font.face_id = FONT;
		desc.image_type = ftc_image_mono;
#endif
		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("Clock <allocating of Backbuffer failed>\n");
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);

		startx = sx;
		starty = sy;
		xstep/=(double)slow;
		ystep/=(double)slow;
		
		InitRC();

	while(loop)
	{
		usleep(15000L);
		ioctl(fb, FBIOGETCMAP, &colormap);
		found=0;
		trnsp=0;
		for(i=colormap.start;i<colormap.len && found!=7;i++)
		{
			if(!colormap.red[i] && !colormap.green[i] && !colormap.blue[i] && !colormap.transp[i])
			{
				cmc=i;
				found|=1;
			}
			if(colormap.red[i]>=0xF000 && colormap.green[i]>=0xF000  && colormap.blue[i]>=0xF000 && !colormap.transp[i])
			{
				cmct=i;
				found|=2;
			}
			if(colormap.transp[i]>trnsp)
			{
				trnspi=i;
				trnsp=colormap.transp[i];
				found|=4;
			}
		}
		if(first)
		{
			first=0;
			memset(lbb, (bcol==0)?trnspi:((bcol==1)?cmc:cmct), var_screeninfo.xres*var_screeninfo.yres);
			memset(lfb, (bcol==0)?trnspi:((bcol==1)?cmc:cmct), var_screeninfo.xres*var_screeninfo.yres);
		}
		if(big)
		{
			x0=3;
			x1=14;
			x2=26;
			x3=BIG;
			x4=30;
			x5=60;
		}
		else
		{
			x0=7;
			x1=12;
			x2=18;
			x3=MED;
			x4=18;
			x5=40;
		}
		x6=0;
		x7=0;
		time(&atim);
		ltim=localtime(&atim);
		if(secs)
		{
			sprintf(tstr,"%02d:%02d:%02d",ltim->tm_hour,ltim->tm_min,ltim->tm_sec);
		}
		else
		{
			sprintf(tstr,"   %02d%c%02d",ltim->tm_hour,(ltim->tm_sec & 1)?':':' ',ltim->tm_min);
			if(!sdat)
			{
				x6=3;
				x7=36+4*big;
			}
		}

		xpos+=xstep*(double)xdir;
		ypos+=ystep*(double)ydir;

		csx=xpos+x7;
		csy=ypos;
		cex=xpos+x7+100+20*big;
		cey=ypos+x2+2*(1+big)+sdat*x4;
		if(csx<0 || (sx+cex)>=ex)
		{
			xdir*=-1;
			xpos+=xstep*(double)xdir;
			csx=xpos+x7;
			cex=xpos+x7+100+20*big;
			xstep=rand()&3;
			if(!xstep)
			{
				xstep=1;
			}
			xstep/=(double)slow;
		}
		if(csy<0 || (sy+cey)>=ey)
		{
			ydir*=-1;
			ypos+=ystep*(double)ydir;
			csy=ypos;
			cey=ypos+x2+2*(1+big)+sdat*x4;
			ystep=rand()&3;
			if(!ystep || (ystep==3 && ydir==1))
			{
				ystep=1;
			}
			ystep/=(double)slow;
		}

		for(i=x6; i<strlen(tstr); i++)
		{
			*dstr=tstr[i];
			RenderString(dstr, xpos-x0+(i*x1), ypos+x2, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
		}

		if(sdat)
		{
			sprintf(tstr,"%02d.%02d.%02d",ltim->tm_mday,ltim->tm_mon+1,ltim->tm_year-100);
			for(i=0; i<strlen(tstr); i++)
			{
				*dstr=tstr[i];
				RenderString(dstr, xpos-x0+(i*x1), ypos+x5-2-2*big, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
			}
		}

		for(i=0;i<=((sdat)?40:20)*(1+big);i++)
		{
			j=(starty+ypos+i)*var_screeninfo.xres+xpos+startx;
			if((j+100+20*big)<var_screeninfo.xres*var_screeninfo.yres)
			{
				memcpy(lfb+j, lbb+j, 100+20*big);
			}
		}
		
		RenderBox(csx, csy, cex, cey, FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct));

		if(++loop>10)
		{
			if(RCKeyPressed()||ExistFile("/tmp/.ssaver_kill"))
			{
				loop=0;
			}
		}	
	}	

	cmct=0;
	cmc=0;
	for(i=colormap.start;i<colormap.len;i++)
	{
		if(colormap.transp[i]>cmct)
		{
			cmc=i;
			cmct=colormap.transp[i];
		}
	}
	memset(lfb, cmc, var_screeninfo.xres*var_screeninfo.yres);
	FTC_Manager_Done(manager);
	FT_Done_FreeType(library);

	free(lbb);
	munmap(lfb, fix_screeninfo.smem_len);

	close(fb);
	CloseRC();
	remove("/tmp/.ssaver_kill");
	return 0;
}
コード例 #9
0
int main (void)
{
int loop=0, werbung=0, tnet=-1,blit=0,cnum=-1,tv,wflag=1,runtime=0, mut=0, vol=0, tmin=15;
char tstr[40],zapchan[40],msgchan[40];
FILE *fh1;
time_t t1,t2,t3,t4;

	printf("Blockad Version %s\n",P_VERSION);

	if (!ReadConf())
	{
		printf("Blockad <Configuration failed>\n");
	}
	else
	{
		if((fh1=fopen(FLG_FILE,"r"))!=NULL)
		{
			if(fgets(zapchan, sizeof(zapchan), fh1))
			{
				Trim_String(zapchan);
				if(fgets(tstr, sizeof(tstr), fh1))
				{
					sscanf(tstr,"%d",&cnum);
					if(fgets(tstr, sizeof(tstr), fh1))
					{
						sscanf(tstr,"%d",&rezap);
						if(fgets(msgchan, sizeof(msgchan), fh1))
						{
							Trim_String(msgchan);
						}
						else
						{
							sprintf(msgchan,"Unbekannt");
						}
						if(fgets(tstr, sizeof(tstr), fh1))
						{
							if(sscanf(tstr,"%d",&vol)==1)
							{
								if(volume)
								{
									if(fgets(tstr, sizeof(tstr), fh1))
									{
										if(sscanf(tstr,"%d",&mut)!=1)
										{
											mut=0;
										}
									}
								}
							}
						}
						if(fgets(tstr, sizeof(tstr), fh1))
						{
							if(sscanf(tstr,"%d",&tmin)!=1)
							{
								tmin=15;
							}
						}
					}
				}
				else
				{
					rezap=420;
				}	
				loop=1;
				if(cnum<0)
				{
					inet=-1;
				}
			}
			fclose(fh1);
		}
		time(&t1);
		t4=t3=t1;
#ifdef HAVE_DBOX_HARDWARE
		LCD_Init();
#endif
		if(inet>=0)
		{
			if(Open_Socket()==-1)
			{
				inet=-1;
			}
		}
		while(loop)
		{
			time(&t2);
			if(inet>=0)
			{
				tnet=-1;
				if(inet>=0)
				{
					tv=Check_Socket(cnum,&werbung);
					if(!werbung)
					{
						if((t2-t4)>tmin)
						{
							Do_Rezap(zapchan,vol,mut);
							loop=0;
						}
					}
					else
					{
						t4=t2;
					}
					if(tv>=0)
					{
						tnet=inet;
					}
				}
				inet=tnet;
			}
			if(loop)
			{
				if((fh1=fopen(FLG_FILE,"r"))!=NULL)
				{
					fclose(fh1);
					if(inet>=0)
					{
						if(wflag)
						{
							fh1=fopen(STS_FILE,"w");
							fprintf(fh1,"%s\n",msgchan);
							fprintf(fh1,"Auto\n");
							fclose(fh1);
							wflag=0;
						}
						if(t3!=t2)
						{
							sprintf(tstr,"%s",(blit^=1)?"   ":" WZ");
#ifdef HAVE_DBOX_HARDWARE
							LCD_Read();
							LCD_draw_string(97, 13, tstr);
							LCD_update();
#endif
							t3=t2;
						}
						sleep(1);
					}
					else
					{
						runtime=t2-t1;
						if(runtime>rezap)
						{
							Do_Rezap(zapchan,vol,mut);
							loop=0;
						}
						else
						{
							if(t3!=t2)
							{
								runtime=rezap-runtime;
								sprintf(tstr,"%2d:%02d",runtime/60,runtime%60);
								fh1=fopen(STS_FILE,"w");
								fprintf(fh1,"%s\n",msgchan);
								fprintf(fh1,"%s\n",tstr);
								fclose(fh1);
#ifdef HAVE_DBOX_HARDWARE
								LCD_Read();
								LCD_draw_string(81, 13, tstr);
								LCD_update();
#endif
								sleep(1);
								t3=t2;
							}
						}
					}
				}
				else
				{
					loop=0;
				}
			}
		}
	}
#ifdef HAVE_DBOX_HARDWARE
	LCD_Close();
#endif
	if(inet>=0)
	{
		Close_Socket();
	}
	sprintf(tstr,"cd /tmp\nrm blockads.*");
	system(tstr);

	return 0;
}
コード例 #10
0
ファイル: clock.c プロジェクト: UkCvs/ukcvs
int main (int argc, char **argv)
{
	unsigned int margin_left_F, digit_width, margin_top_t, font_size, margin_top_box, margin_top_d, digits, secs_width, adj_height;
	int i = 0;
	int j = 0;
	int w = 0;
	int ms = 0;
	int mw = 0;
	int loop = 1;
	unsigned int newmail = 0;
	unsigned int mailgfx = 0;
	int xdir = 1, ydir = 1;
	double xstep = 1, ystep = 1; 
	double csx, cex, csy, cey;
	time_t atim;
	struct tm *ltim;
	char *aptr,*rptr;
	char dstr[2] = {0,0};
	FILE *tfh;

		printf("Clock / SSaver Version %s\n",CL_VERSION);

		for (i = 1; i < argc; i++)
		{
			if (!strncmp(argv[i], "-ss", 3))
			{
				ssaver = 1;
				continue;
			}
		}

		if (ssaver)
		{
			time(&atim);
			srand((unsigned int)atim);
			ReadConf(SCFG_FILE);
		}
		else
		{
			ReadConf(CCFG_FILE);
		}

		for (i = 1; i < argc; i++)
		{
			aptr=argv[i];
			if((rptr=strchr(aptr,'='))!=NULL)
			{
				rptr++;
				if (!ssaver)
				{
					if(strstr(aptr,"X=")!=NULL)
					{
						if(sscanf(rptr,"%d",&j)==1)
						{
							xpos=j;
						}
					}	
					if(strstr(aptr,"Y=")!=NULL)
					{
						if(sscanf(rptr,"%d",&j)==1)
						{
							ypos=j;
						}
					}
					if(strstr(aptr,"MAIL=")!=NULL)
					{
						if(sscanf(rptr,"%d",&j)==1)
						{
							mail=j;
						}
					}
				}
				if(strstr(aptr,"DATE=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						show_date=j;
					}
				}
				if(strstr(aptr,"BIG=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						big=(j)?1:0;
					}
				}
				if(strstr(aptr,"SEC=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						show_sec=j;
					}
				}
				if(strstr(aptr,"BLINK=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						blink=j;
					}
				}
				if(strstr(aptr,"SLOW=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						if(!j)
						{
							j=1;
						}
						slow=j;
					}
				}
				if(strstr(aptr,"FCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						fcol=j;
					}
				}
				if(strstr(aptr,"BCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						bcol=j;
					}
				}
			}
		}
		if((sx=Read_Neutrino_Cfg("screen_StartX"))<0)
			sx=80;
		
		if((ex=Read_Neutrino_Cfg("screen_EndX"))<0)
			ex=620;

		if((sy=Read_Neutrino_Cfg("screen_StartY"))<0)
			sy=80;

		if((ey=Read_Neutrino_Cfg("screen_EndY"))<0)
			ey=505;
		
		fb = open(FB_DEVICE, O_RDWR);

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("Clock / SSaver <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("Clock / SSaver <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("Clock / SSaver <mapping of Framebuffer failed>\n");
			return -1;
		}

	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("Clock / SSaver <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("Clock / SSaver <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("Clock / SSaver <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
		{
			printf("Clock / SSaver <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		use_kerning = FT_HAS_KERNING(face);

#ifdef FT_NEW_CACHE_API
		desc.face_id = FONT;
#else
		desc.font.face_id = FONT;
#endif
#if FREETYPE_MAJOR  == 2 && FREETYPE_MINOR == 0
		desc.image_type = ftc_image_mono;
#else
		desc.flags = FT_LOAD_MONOCHROME;
#endif

		//init backbuffer

		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("Clock / SSaver <allocating of Backbuffer failed>\n");
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if (!slow)
			slow=1;

		if (slow>10)
			slow=10;

		if (fcol > MAXCOL && !(ssaver == 1 && fcol == 99))
			fcol = 2;
		if (bcol > 3 && !(bcol == 10))
			bcol = 1;

		if (ssaver)
		{
			memset(lbb, col[bcol], var_screeninfo.xres*var_screeninfo.yres);
			memset(lfb, col[bcol], var_screeninfo.xres*var_screeninfo.yres);
		}
		else
			memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);

		if (big)			//grosse Schrift (time/date)
		{
			margin_left_F = 3;			// 3
			digit_width = 14;			// 14
			margin_top_t = 26;			// 26
			font_size = BIG;			// 40
			margin_top_box = 30;		// 30
			margin_top_d = 60;			// 60
		}
		else
		{
			margin_left_F = 7;			//7  Abstand links
			digit_width = 12;			//12 Ziffernblockbreite
			margin_top_t = 19;			//19 Abstand "TimeString"-Unterkante von oben
			font_size = MED;			//30 Schriftgroesse
			margin_top_box = 20;		//20 Abstand Renderbox von oben
			margin_top_d = 40;			//40 Abstand "DateString" von oben
		}
		digits = 0;
		secs_width = 0;
		startx = sx;
		starty = sy;
		mw = (big) ? 42 : 36;			//mailwidth
		adj_height = 1 * (!big && !show_date); //max steprange == 3, so we need always a top/bottom margin of >=3

		if (!show_sec && !show_date)
		{
			digits = 3;				//3 Platzhalter ':ss'
			secs_width = digits * digit_width;
		}

		if (ssaver)
		{
			xpos = rand() %480 + 10;
			ypos = rand() %460 + 10;	
			xdir *= (rand() &1) == 0 ? -1 : 1;
			ydir *= (rand() &1) == 0 ? -1 : 1;
			xstep/=(double)slow;
			ystep/=(double)slow;
			if (fcol == 99)
			{
				cCol = 1;
				Change_Col(&fcol, &bcol);
			}
			InitRC();
		}

	while (loop)
	{
		if (ssaver)
			usleep(15000L);
		else
		{
			usleep(150000L);
			newmail = 0;
			if(mail && ExistFile(MAIL_FILE))
			{
				if((tfh = fopen(MAIL_FILE,"r")) != NULL)
				{
					if(fgets(tstr, 511, tfh))
					{
						if(sscanf(tstr, "%d", &i))
						{
							newmail = i;
						}
					}
					fclose(tfh);
				}
			}
		}

		time(&atim);
		ltim=localtime(&atim);
		if (show_sec)
		{
			sprintf(tstr,"%02d:%02d:%02d", ltim->tm_hour, ltim->tm_min, ltim->tm_sec);
		}
		else
		{
			if (blink)
				sprintf(tstr,"   %02d%c%02d", ltim->tm_hour, (ltim->tm_sec & 1)? ' ' : ':', ltim->tm_min);
			else
				sprintf(tstr,"   %02d:%02d", ltim->tm_hour, ltim->tm_min);
		}

		if (!ssaver)
		{
			if (((int)xpos >= mw) || (!show_sec))
			{
				ms = (int)xpos + ((show_sec) ? 0 : mw) - mw;	//mail left
			}
			else
			{
				ms = (int)xpos + 100 + 20 * big;		//mail right
			}
			//paint Backgroundcolor to clear digit
			RenderBox(xpos+secs_width, ypos, xpos+secs_width+100+20*big, ypos+margin_top_box + adj_height, FILL, col[bcol]);
		}

		if (ssaver)
		{
			xpos += xstep * (double)xdir;
			ypos += ystep * (double)ydir;

			csx = xpos + secs_width;
			csy = ypos;
			cex = xpos + secs_width + 100 + 20 * big;
			cey = ypos + margin_top_t + 2 * (1 + big) + (margin_top_box * show_date) + adj_height;

			if ((int)csx < 0 || (sx + (int)cex) > ex)
			{
				if (cCol)
					Change_Col(&fcol, &bcol);
				xdir *= -1;
				xpos += xstep * (double)xdir;
				csx = xpos + secs_width;
				cex = xpos + secs_width + 100 + 20 * big;
				xstep = rand() &3;
				if (!xstep)
				{
					xstep = 1;
				}
				xstep /= (double)slow;
			}
			if ((int)csy < 0 || (sy + (int)cey) > ey)
			{
				if (cCol)
					Change_Col(&fcol, &bcol);
				ydir *= -1;
				ypos += ystep * (double)ydir;
				csy = ypos;
				cey = ypos + margin_top_t + 2 * (1 + big) + (margin_top_box * show_date) + adj_height;	
				ystep = rand() &3;
				if (!ystep)
				{
					ystep = 1;
				}
				ystep /= (double)slow;
			}
			RenderBox(csx, csy, cex, cey, FILL, col[bcol]);
		}

		for (i = digits; i < strlen(tstr); i++)
		{
			*dstr = tstr[i];
			RenderString(dstr, xpos - margin_left_F + (i * digit_width), ypos + margin_top_t, 30, CENTER, font_size, col[fcol]);
		}

		if (show_date)
		{
			sprintf(tstr, "%02d.%02d.%02d", ltim->tm_mday, ltim->tm_mon + 1, ltim->tm_year - 100);
			if (!ssaver)
			{
			//Backgroundbox color Date
			RenderBox(xpos, ypos + margin_top_box, xpos + 100 + 20 * big, ypos + margin_top_d, FILL, col[bcol]);
			}
			for(i = 0; i < strlen(tstr); i++)
			{
				*dstr = tstr[i];
				RenderString(dstr, xpos - margin_left_F + (i * digit_width), ypos + margin_top_d - 2 - (2 * big), 30, CENTER, font_size, col[fcol]);
			}
		}

		if (ssaver)
		{
			w = 100 + 20 * big + ((show_sec) ? 0 : - secs_width);
			for (i = 0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++)
			{
				j = (starty + (int)ypos + i) * var_screeninfo.xres + (int)xpos + ((show_sec) ? 0 : secs_width) + startx;
				if ((j + w) < var_screeninfo.xres * var_screeninfo.yres)
				{
					memcpy(lfb+j, lbb+j, w);
				}
			}
		}
		else
		{
			if (newmail > 0)
			{
				mailgfx = 1;

				//Background mail, left site from clock
				RenderBox(ms, ypos, ms+mw, ypos+margin_top_box + adj_height, FILL, col[bcol]); //bcol

				if(!(ltim->tm_sec & 1))
				{
					RenderBox (ms+8, ypos+5+(1+big), ms+mw-8, ypos+margin_top_box+adj_height-2-(3*big), GRID,	col[fcol]);
					DrawLine  (ms+8, ypos+5+(1+big), ms+mw-8, ypos+margin_top_box+adj_height-2-(3*big),			col[fcol]);
					DrawLine  (ms+8, ypos+margin_top_box+adj_height-2-(3*big), ms+mw-8, ypos+5+(1+big),			col[fcol]);
					DrawLine  (ms+(9+1*big), ypos+4+(1+big), ms+(mw/2), ypos+1,                  				col[fcol]);
					DrawLine  (ms+(9+1*big), ypos+5+(1+big), ms+(mw/2), ypos+2,                  				col[fcol]);
					DrawLine  (ms+(mw/2), ypos+1, ms+mw-(9+1*big), ypos+4+(1+big),               				col[fcol]);
					DrawLine  (ms+(mw/2), ypos+2, ms+mw-(9+1*big), ypos+5+(1+big),               				col[fcol]);
				}
				else
				{
					sprintf(tstr,"%d",newmail);
					RenderString(tstr, ms, ypos+margin_top_t, mw, CENTER, font_size, col[fcol]);
				}
			}
			else
			{
				if (mailgfx > 0)
					RenderBox(ms, ypos, ms+mw, ypos + margin_top_box + adj_height, FILL, (!show_date || show_sec) ? TRANSP : col[bcol]);
				else
					ms=(int)xpos;
			}

			w = 100 + 20 * big + ((mailgfx) ? ((show_sec) ? mw : 0) : - secs_width);
			for (i=0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++)
			{
				j = (starty + (int)ypos + i) * var_screeninfo.xres + ( ((ms < (int)xpos) ? ms : (int)xpos) + ((show_sec) ? 0 : ((mailgfx) ? 0 : secs_width)) ) + startx;			
				if ((j + w) < var_screeninfo.xres * var_screeninfo.yres)
				{
					memcpy(lfb+j, lbb+j, w);
				}
			}
			if (newmail == 0 && mailgfx > 0)
				mailgfx = 0;
		}

		if (++loop > 10)
		{
			if ( (ssaver && (RCKeyPressed() || ExistFile("/tmp/.ssaver_kill")))
				|| (!ssaver && ExistFile("/tmp/.clock_kill")) )
				loop = 0;
		}
	}


/****************************
 * close down Clock / SSaver
 ****************************/
	if (ssaver)
	{
		memset(lfb, 0, var_screeninfo.xres*var_screeninfo.yres);
		remove("/tmp/.ssaver_kill");
		CloseRC();
	}
	else
	{
		memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);
		remove("/tmp/.clock_kill");
		for (i=0; i <= ((show_date) ? 20 : 10) * (2 + big) + adj_height; i++)
		{
			j=(starty+(int)ypos+i)*var_screeninfo.xres+((ms<(int)xpos)?ms:(int)xpos)+((show_sec)?0:((mailgfx)?0:secs_width))+startx;
			if((j+100+20*big+((mail)?mw:0))<var_screeninfo.xres*var_screeninfo.yres)
			{
				memcpy(lfb+j, lbb+j, w);
			}
		}
	}

	FTC_Manager_Done(manager);
	FT_Done_FreeType(library);

	free(lbb);
	munmap(lfb, fix_screeninfo.smem_len);

	close(fb);

	return 0;
}
コード例 #11
0
ファイル: m_pgsql.cpp プロジェクト: thepaul/inspircd-deb
	virtual void OnRehash(User* user)
	{
		ReadConf();
	}
コード例 #12
0
ファイル: blockads.c プロジェクト: OpenDMM/tuxbox-apps
/******************************************************************************
 * Blockads Main
 ******************************************************************************/
int main (void)
{
int loop=0,found,werbung=0,tnet, tv, cnum=-1;
char tstr[512],line_buffer[512],zapchan[40],srcchan[40],*cpt1=NULL;
FILE *fh1,*fh2;

	printf("Blockads Version %s\n",P_VERSION);
	
	if((fh1=fopen(FLG_FILE,"r"))==NULL)
	{
//		system("ping -c 5 google.com &");
		fb = open(FB_DEVICE, O_RDWR);
		rc = open(RC_DEVICE, O_RDONLY);
		fcntl(rc, F_SETFL, (fcntl(rc, F_GETFL) | O_EXCL) & ~O_NONBLOCK);


		if((sx=Read_Neutrino_Cfg("screen_StartX"))<0)
			sx=80;
		
		if((ex=Read_Neutrino_Cfg("screen_EndX"))<0)
			ex=620;

		if((sy=Read_Neutrino_Cfg("screen_StartY"))<0)
			sy=80;

		if((ey=Read_Neutrino_Cfg("screen_EndY"))<0)
			ey=505;

		if(Read_Neutrino_Cfg("rounded_corners")>0)
			radius=9;
		else
			radius=0;

	//init framebuffer
		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("Blockads <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("Blockads <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		
		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("Blockads <mapping of Framebuffer failed>\n");
			return -1;
		}
	
	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("Tuxwetter <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("Tuxwetter <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("Tuxwetter <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
		{
			printf("Tuxwetter <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		use_kerning = FT_HAS_KERNING(face);

#ifdef FT_NEW_CACHE_API
		desc.face_id = FONT;
		desc.flags = FT_LOAD_MONOCHROME;
#else
		desc.font.face_id = FONT;
		desc.image_type = ftc_image_mono;
#endif
	//init backbuffer
		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("Blockads <allocating of Backbuffer failed>\n");
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		memset(lbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres);
	
		if (!ReadConf())
		{
			printf("Blockads <Configuration failed>\n");
			return -1;
		}
		found=0;
		loop=0;
		if(!HTTP_downloadFile("localhost",80,"/control/channellist", LST_FILE, 0, 1))
		{
			if(!HTTP_downloadFile("localhost",80,"/control/zapto", ZAP_FILE, 0, 1))
			{
				if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
				{
					while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && (strlen(line_buffer)<4));
					if(strlen(line_buffer)>1)
					{
						Trim_String(line_buffer);
						strcpy(zapchan,line_buffer);
						if((fh2=fopen(LST_FILE,"r"))!=NULL)
						{
							while(!found && (fgets(line_buffer, sizeof(line_buffer), fh2)))
							{
								if(strstr(line_buffer,zapchan)==line_buffer)
								{
									if((cpt1=strchr(line_buffer,' '))!=NULL)
									{
										cpt1++;
										Trim_String(cpt1);
										strcpy(msgchan,cpt1);
										loop=1;
										if(!Translate_Channel(cpt1, tstr))
										{
											cnum=Get_ChannelNumber(tstr);
											strcpy(srcchan,tstr);
											found=1;
										}
									}
								}
							}
							if(!found)
							{
								inet=-1;
							}
							fclose(fh2);
						}
					}
					fclose(fh1);
				}
			}
		}		
		if(!loop)
		{
			sprintf(tstr,"Fehler beim Auslesen der Kanalliste.\nPlugin konnte nicht gestartet werden.");
			Msg_Popup(tstr);
			return -1;
		}
		if(volume)
		{
			volume=0;
			if(!HTTP_downloadFile("localhost",80,"/control/volume?status", ZAP_FILE, 0, 1))
			{
				if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
				{
					while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && !strlen(line_buffer));
					if(strlen(line_buffer)>=1)
					{
						Trim_String(line_buffer);
						sscanf(line_buffer,"%d",&mute);
					}
					fclose(fh1);
				}
			}
			if(!HTTP_downloadFile("localhost",80,"/control/volume", ZAP_FILE, 0, 1))
			{
				if((fh1=fopen(ZAP_FILE,"r"))!=NULL)
				{
					while((fgets(line_buffer, sizeof(line_buffer), fh1)>0) && !strlen(line_buffer));
					if(strlen(line_buffer)>=1)
					{
						Trim_String(line_buffer);
						sscanf(line_buffer,"%d",&volume);
					}
					fclose(fh1);
				}
			}
		}
		if(inet>=0)
		{
			tnet=-1;
			if(Open_Socket()!=-1)
			{
				tv=Check_Socket(cnum,&werbung);
				if(tv>0)
				{
					tnet=inet;
					if(!werbung)
					{
						if(!zapalways)
						{
							int adf=0;

							sprintf(tstr,"Für Kanal %s wird\nmomentan keine Werbung gemeldet.\nWerbung läuft im Augenblick auf:\n",msgchan);
							for(tv=0; tv<NUM_CHANNELS; tv++)
							{
								Check_Channel(tv,&found);
								if(found)
								{
									sprintf(tstr+strlen(tstr),"\n%s",Get_ChannelName(tv));
									adf=1;
								}
							}
							if(!adf)
							{
								sprintf(tstr+strlen(tstr),"\nkeinem anderen Sender");
							}
							Msg_Popup(tstr);
							loop=0;
						}
						else
						{
							tnet=-1;
						}
					}
					else
					{
						if((fh2=fopen(FLG_FILE,"w"))!=NULL)
						{
							int adf=0;
							
							fprintf(fh2,"%s\n%d\n%d\n%s\n%d\n%d\n%d\n",zapchan,cnum,rezap*60,msgchan,volume,mute,debounce);
							fclose(fh2);
							system("/bin/blockad &");
							sprintf(tstr,"Werbezapper fr Kanal %s aktiviert.\nSie können jetzt umschalten.\n\nWerbung läuft im Augenblick auch auf:\n",msgchan);
							for(tv=0; tv<NUM_CHANNELS; tv++)
							{
								Check_Channel(tv,&found);
								if(found && (tv != cnum))
								{
									sprintf(tstr+strlen(tstr),"\n%s",Get_ChannelName(tv));
									adf=1;
								}
							}
							if(!adf)
							{
								sprintf(tstr+strlen(tstr),"\nkeinem anderen Sender");
							}
							Msg_Popup(tstr);
						}
					}
				}
				Close_Socket();
			}
			inet=tnet;
		}
		if(inet==-1 && loop)
		{
			Start_NoInet(zapchan);
		}
	}
	else
	{
		Msg_Popup("Werbezapper deaktiviert");
		remove(FLG_FILE);
		sleep(2);
	}

	// clear Display
	memset(lbb, TRANSP, var_screeninfo.xres*var_screeninfo.yres);
	memcpy(lfb, lbb, var_screeninfo.xres*var_screeninfo.yres);
	munmap(lfb, fix_screeninfo.smem_len);
	close(fb);
	free(lbb);

	FTC_Manager_Done(manager);
	FT_Done_FreeType(library);


	fcntl(rc, F_SETFL, O_NONBLOCK);
	
	close(rc);

	return 0;
}
コード例 #13
0
ファイル: clock.c プロジェクト: TitanNit/tdt
int main (int argc, char **argv)
{
	int tv,index,i,j,k,w,cmct=CMCT,cmc=CMC,trnspi=TRANSP,trnsp=0,found,loop=1,x0,x1,x2,x3,x4,x5,x6,x7,ms,mw,newmail=0;
	time_t atim;
	struct tm *ltim;
	char *aptr,*rptr;
	char dstr[2]={0,0};
	FILE *tfh;

		printf("Clock Version %s\n",CL_VERSION);
		
		ReadConf();
	
		for(i=1; i<argc; i++)
		{
			aptr=argv[i];
			if((rptr=strchr(aptr,'='))!=NULL)
			{
				rptr++;
				if(strstr(aptr,"X=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						xpos=j;
					}
				}
				if(strstr(aptr,"Y=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						ypos=j;
					}
				}
				if(strstr(aptr,"DATE=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						sdat=j;
					}
				}
				if(strstr(aptr,"BIG=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						big=j;
					}
				}
				if(strstr(aptr,"SEC=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						secs=j;
					}
				}
				if(strstr(aptr,"FCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						fcol=j;
					}
				}
				if(strstr(aptr,"BCOL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						bcol=j;
					}
				}
				if(strstr(aptr,"MAIL=")!=NULL)
				{
					if(sscanf(rptr,"%d",&j)==1)
					{
						mail=j;
					}
				}
			}
		}
		if((sx=Read_Neutrino_Cfg("screen_StartX"))<0)
			sx=80;
		
		if((ex=Read_Neutrino_Cfg("screen_EndX"))<0)
			ex=620;

		if((sy=Read_Neutrino_Cfg("screen_StartY"))<0)
			sy=80;

		if((ey=Read_Neutrino_Cfg("screen_EndY"))<0)
			ey=505;
			
		for(index=CMCST; index<=CMH; index++)
		{
			sprintf(tstr,"menu_%s_alpha",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				tr[index-1]=(tv<<8);

			sprintf(tstr,"menu_%s_blue",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				bl[index-1]=(tv+(tv<<8));

			sprintf(tstr,"menu_%s_green",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				gn[index-1]=(tv+(tv<<8));

			sprintf(tstr,"menu_%s_red",menucoltxt[index-1]);
			if((tv=Read_Neutrino_Cfg(tstr))>=0)
				rd[index-1]=(tv+(tv<<8));
		}
		
		fb = open(FB_DEVICE, O_RDWR);

		if(ioctl(fb, FBIOGET_FSCREENINFO, &fix_screeninfo) == -1)
		{
			printf("Clock <FBIOGET_FSCREENINFO failed>\n");
			return -1;
		}
		if(ioctl(fb, FBIOGET_VSCREENINFO, &var_screeninfo) == -1)
		{
			printf("Clock <FBIOGET_VSCREENINFO failed>\n");
			return -1;
		}
		
		if(ioctl(fb, FBIOGETCMAP, &colormap) == -1)
		{
			printf("Clock <FBIOGETCMAP failed>\n");
			return -1;
		}

		if(!(lfb = (unsigned char*)mmap(0, fix_screeninfo.smem_len, PROT_READ | PROT_WRITE, MAP_SHARED, fb, 0)))
		{
			printf("Clock <mapping of Framebuffer failed>\n");
			return -1;
		}

	//init fontlibrary

		if((error = FT_Init_FreeType(&library)))
		{
			printf("Clock <FT_Init_FreeType failed with Errorcode 0x%.2X>", error);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_New(library, 1, 2, 0, &MyFaceRequester, NULL, &manager)))
		{
			printf("Clock <FTC_Manager_New failed with Errorcode 0x%.2X>\n", error);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_SBitCache_New(manager, &cache)))
		{
			printf("Clock <FTC_SBitCache_New failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		if((error = FTC_Manager_Lookup_Face(manager, FONT, &face)))
		{
			printf("Clock <FTC_Manager_Lookup_Face failed with Errorcode 0x%.2X>\n", error);
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		use_kerning = FT_HAS_KERNING(face);

#ifdef FT_NEW_CACHE_API
		desc.face_id = FONT;
#else
		desc.font.face_id = FONT;
#endif
#if FREETYPE_MAJOR  == 2 && FREETYPE_MINOR == 0
		desc.image_type = ftc_image_mono;
#else
		desc.flags = FT_LOAD_MONOCHROME;
#endif

	//init backbuffer

		if(!(lbb = malloc(var_screeninfo.xres*var_screeninfo.yres)))
		{
			printf("Clock <allocating of Backbuffer failed>\n");
			FTC_Manager_Done(manager);
			FT_Done_FreeType(library);
			munmap(lfb, fix_screeninfo.smem_len);
			return -1;
		}

		memset(lbb, 0, var_screeninfo.xres*var_screeninfo.yres);

		startx = sx;
		starty = sy;
		mw=(big)?40:30;

	while(loop)
	{
		usleep(150000L);
		newmail=0;
		if(mail && ExistFile(MAIL_FILE))
		{
			if((tfh=fopen(MAIL_FILE,"r"))!=NULL)
			{
				if(fgets(tstr,511,tfh))
				{
					if(sscanf(tstr,"%d",&i))
					{
						newmail=i;
					}
				}
				fclose(tfh);
			}
		}
		ioctl(fb, FBIOGETCMAP, &colormap);
		found=0;
		trnsp=0;
		for(i=colormap.start;i<colormap.len && found!=7;i++)
		{
			if(!colormap.red[i] && !colormap.green[i] && !colormap.blue[i] && !colormap.transp[i])
			{
				cmc=i;
				found|=1;
			}
			if(colormap.red[i]>=0xF000 && colormap.green[i]>=0xF000  && colormap.blue[i]>=0xF000 && !colormap.transp[i])
			{
				cmct=i;
				found|=2;
			}
			if(colormap.transp[i]>trnsp)
			{
				trnspi=i;
				trnsp=colormap.transp[i];
				found|=4;
			}
		}	

		if(big)
		{
			x0=3;
			x1=14;
			x2=26;
			x3=BIG;
			x4=30;
			x5=60;
		}
		else
		{
			x0=7;
			x1=12;
			x2=18;
			x3=MED;
			x4=18;
			x5=40;
		}
		x6=0;
		x7=0;
		time(&atim);
		ltim=localtime(&atim);
		if(secs)
		{
			sprintf(tstr,"%02d:%02d:%02d",ltim->tm_hour,ltim->tm_min,ltim->tm_sec);
		}
		else
		{
			sprintf(tstr,"   %02d%c%02d",ltim->tm_hour,(ltim->tm_sec & 1)?':':' ',ltim->tm_min);
			if(!sdat)
			{
				x6=3;
				x7=36+4*big;
			}
		}
		if((xpos>=mw)||(!secs))
		{
			ms=xpos+((secs)?0:36+4*big)-mw;
		}
		else
		{
			ms=xpos+100+20*big;
		}
		k=((ms>xpos)&&mail)?mw:0;
		RenderBox(xpos+x7, ypos, xpos+x7+100+20*big, ypos+x2+2*(1+big), FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct));
		for(i=x6; i<strlen(tstr); i++)
		{
			*dstr=tstr[i];
			RenderString(dstr, xpos-x0+(i*x1), ypos+x2, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
		}

		if(sdat)
		{
			sprintf(tstr,"%02d.%02d.%02d",ltim->tm_mday,ltim->tm_mon+1,ltim->tm_year-100);
			RenderBox(xpos, ypos+x4, xpos+100+20*big, ypos+x5, FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct));
			for(i=0; i<strlen(tstr); i++)
			{
				*dstr=tstr[i];
				RenderString(dstr, xpos-x0+(i*x1), ypos+x5-2-2*big, 30, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
			}
		}
		if(mail)
		{
			if(newmail)
			{
				RenderBox(ms, ypos, ms+mw, ypos+x2+2*(1+big), FILL, (bcol==0)?trnspi:((bcol==1)?cmc:cmct));
				if(!(ltim->tm_sec & 1))
				{
					RenderBox(ms+5, ypos+5+(1+big), ms+mw-5, ypos+x2+(1+big)-2, GRID, (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+5, ypos+5+(1+big), ms+mw-5, ypos+x2+(1+big)-2, (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+5, ypos+x2+(1+big)-2, ms+mw-5, ypos+5+(1+big), (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+5, ypos+5+(1+big), ms+((mw-2)/2), ypos+2, (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+6, ypos+6+(1+big), ms+((mw-2)/2)+1, ypos+3, (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+((mw-2)/2), ypos+2, ms+mw-5, ypos+5+(1+big), (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
					DrawLine(ms+((mw-2)/2)+1, ypos+3, ms+mw-6, ypos+6+(1+big), (fcol==0)?trnspi:((fcol==1)?cmc:cmct));
				}
				else
				{
					sprintf(tstr,"%d",newmail);
					RenderString(tstr, ms, ypos+x2, mw, CENTER, x3, (fcol==0)?trnspi:((fcol==2)?cmct:cmc));
				}
			}
			else
			{
				if(!sdat || secs)
				{
					RenderBox(ms+((ms>(xpos+100))?1:0), ypos, ms+mw-((k)?0:1), ypos+x2+2*(1+big), FILL, trnspi);
				}
			}
		}
		else
		{
			ms=xpos;
		}
		
		w=100+20*big+((mail)?5*big+((secs)?mw:0):0)+k-((k&&!sdat)?mw:0);
		for(i=0;i<=((sdat)?40:20)*(1+big);i++)
		{
			j=(starty+ypos+i)*var_screeninfo.xres+((ms<xpos)?ms:xpos)+startx;
			if((j+w)<var_screeninfo.xres*var_screeninfo.yres)
			{
				memcpy(lfb+j, lbb+j, w);
			}
		}
		if(++loop>5)
		{
			if(ExistFile("/tmp/.clock_kill"))
			{
				loop=0;
			}
		}	
	}	

	cmct=0;
	cmc=0;
	for(i=colormap.start;i<colormap.len;i++)
	{
		if(colormap.transp[i]>cmct)
		{
			cmc=i;
			cmct=colormap.transp[i];
		}
	}
	memset(lbb, cmc, var_screeninfo.xres*var_screeninfo.yres);
	for(i=0;i<=((sdat)?40:20)*(1+big);i++)
	{
		j=(starty+ypos+i)*var_screeninfo.xres+((ms<xpos)?ms:xpos)+startx;
		if((j+100+20*big+((mail)?mw:0))<var_screeninfo.xres*var_screeninfo.yres)
		{
			memcpy(lfb+j, lbb+j, w);
		}
	}
	FTC_Manager_Done(manager);
	FT_Done_FreeType(library);

	free(lbb);
	munmap(lfb, fix_screeninfo.smem_len);

	close(fb);
	remove("/tmp/.clock_kill");
	return 0;
}
コード例 #14
0
int main( int argc ATTR_UNUSED, char **argv )
{
	DSpec dspec;
	ValArr va;
	char *ci, *disp, *dcls, *cfgfile;
	int what;

	if (!(ci = getenv( "CONINFO" ))) {
		fprintf( stderr, "This program is part of kdm and should not be run manually.\n" );
		return 1;
	}
	if (sscanf( ci, "%d %d", &rfd, &wfd ) != 2)
		return 1;

	InitLog();

	if ((debugLevel = GRecvInt()) & DEBUG_WCONFIG)
		sleep( 100 );

/*	Debug ("parsing command line\n");*/
	if (**++argv)
		kdmrc = *argv;
/*
	while (*++argv) {
	}
*/

	for (;;) {
/*		Debug ("Awaiting command ...\n");*/
		if (!GRecvCmd( &what ))
			break;
		switch (what) {
		case GC_Files:
/*			Debug ("GC_Files\n");*/
			ReadConf();
			CopyValues( 0, &secGeneral, 0, C_CONFIG );
#ifdef XDMCP
			CopyValues( 0, &secXdmcp, 0, C_CONFIG );
			GSendInt( 2 );
#else
			GSendInt( 1 );
#endif
			GSendStr( kdmrc );
				GSendInt( -1 );
#ifdef XDMCP
			GSendNStr( VXaccess.ptr, VXaccess.len - 1 );
				GSendInt( 0 );
#endif
			for (; (what = GRecvInt()) != -1; )
				switch (what) {
				case GC_gGlobal:
				case GC_gDisplay:
					GSendInt( 0 );
					break;
#ifdef XDMCP
				case GC_gXaccess:
					GSendInt( 1 );
					break;
#endif
				default:
					GSendInt( -1 );
					break;
				}
			break;
		case GC_GetConf:
/*		Debug( "GC_GetConf\n" );*/
			memset( &va, 0, sizeof(va) );
			what = GRecvInt();
			cfgfile = GRecvStr();
			switch (what) {
			case GC_gGlobal:
/*		Debug( "GC_gGlobal\n" );*/
				Debug( "getting global config\n" );
				ReadConf();
				CopyValues( &va, &secGeneral, 0, 0 );
#ifdef XDMCP
				CopyValues( &va, &secXdmcp, 0, 0 );
#endif
				CopyValues( &va, &secShutdown, 0, 0 );
				SendValues( &va );
				break;
			case GC_gDisplay:
/*		Debug( "GC_gDisplay\n" );*/
				disp = GRecvStr();
/*		Debug( " Display %s\n", disp );*/
				dcls = GRecvStr();
/*		Debug( " Class %s\n", dcls );*/
				Debug( "getting config for display %s, class %s\n", disp, dcls );
				MkDSpec( &dspec, disp, dcls ? dcls : "" );
				ReadConf();
				CopyValues( &va, &sec_Core, &dspec, 0 );
				CopyValues( &va, &sec_Greeter, &dspec, 0 );
				free( disp );
				if (dcls)
					free( dcls );
				SendValues( &va );
				break;
#ifdef XDMCP
			case GC_gXaccess:
				ReadAccessFile( cfgfile );
				break;
#endif
			default:
				Debug( "Unsupported config category %#x\n", what );
			}
			free( cfgfile );
			break;
		default:
			Debug( "Unknown config command %#x\n", what );
		}
	}

/*	Debug( "Config reader exiting ..." );*/
	return EX_NORMAL;
}
コード例 #15
0
ファイル: ConfManager.cpp プロジェクト: BDT-GER/SWIFT-TLC
	ConfManager::ConfManager(const string& confFile)
	{
		ReadConf(confFile);
		curSection_ = "";
	}
コード例 #16
0
ファイル: server.cpp プロジェクト: Seikareikou/symbian
void CMyServer::ReadConf()
    {
    __LOGSTR("ReadConf");
    if(iFile.Open(iFs,KFileConfig,EFileRead) != KErrNone)
	{//file not exist
    __LOGSTR("File not exist");
	TInt err = iFs.MkDirAll(KFileConfigDir);
	__LOGSTR1("Mkdir: %d",err);
	iFile.Replace(iFs,KFileConfig,EFileRead|EFileWrite);
	TFileText text;
	iFile.Write(0,_L8("\xff\xfe"));//signature
	text.Set(iFile);
	text.Write(_L("140"));//iX
	text.Write(_L("190"));//iY
	text.Write(_L("120"));//iLandY
	text.Write(_L("150"));//iLandX
	text.Write(_L("15"));//iHeight
	text.Write(_L("0xffffff"));//TRgb white

	text.Write(_L("0x102750f0"));//default UID
	iFile.Close();
	ReadConf();
	}else{
	__LOGSTR("File exist");
	//file exist
	TFileText text;
	TLex lex;
	TBuf<32> buf;
	text.Set(iFile);
	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iX);

	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iY);

	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iLandY);

	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iLandX);

	text.Read(buf);
	lex.Assign(buf);
	lex.Val(iConfig.iHeight);

	text.Read(buf);
	if(buf.Left(2)==_L("0x"))
		buf.Delete(0,2);
	lex.Assign(buf);
	TUint32 rgb;
	lex.Val(rgb,EHex);
	iConfig.iColor = rgb;

	text.Read(buf);
	buf.Delete(0,2); // delete 0x
	lex.Assign(buf);
	TUint tempuid;
	lex.Val(tempuid,EHex);
	iConfig.iUid.iUid = tempuid;

	iFile.Close();
	}
    }
コード例 #17
0
ファイル: server.cpp プロジェクト: Seikareikou/symbian
void CMyServer::ConstructL()
    {
    #ifdef __DEBUG
    __LOGSTR("Construct");
    #endif
    CActiveScheduler::Add(this);
    iWs = RWsSession();
    iFs.Connect();
    ReadConf();
    #ifdef __DEBUG
    __LOGSTR("ReadConfComplete");
    #endif

    iWs.Connect(iFs);
    iTaskList = new(ELeave) TApaTaskList(iWs);

    iScreen = new(ELeave) CWsScreenDevice(iWs);
    CleanupStack::PushL(iScreen);
    iScreen->Construct();
    CleanupStack::Pop(iScreen);
    iEngine = CreateProfileEngineL();
    iOldName = iEngine->ActiveProfileL()->ProfileName().Name();

    //__LOGSTR1("name:%S",&iEngine->ActiveProfileL()->ProfileName().Name());
    // get font name
    	TTypefaceSupport iTypefaceSupport;
    	TBuf<KMaxTypefaceNameLength> fontName;
    	fontName.FillZ(KMaxTypefaceNameLength);
    	iScreen->TypefaceSupport(iTypefaceSupport, 0);
    	fontName = iTypefaceSupport.iTypeface.iName;
    	// get font
    	TFontSpec FontSpec(fontName, 10*iConfig.iHeight);
    	FontSpec.iTypeface.SetIsProportional(ETrue);
    	iScreen->GetNearestFontInTwips(iFont,FontSpec);

    	iIsVisible=EFalse;
    	//calculate size
    //	TBuf<150> temp;
    	//temp.Fill('P',150);
    	iSize=TSize(iFont->TextWidthInPixels(iOldName),iFont->HeightInPixels()*2+3);
    	//__LOGSTR2("iFont->TextWidthInPixels(temp):%d,iFont->HeightInPixels()*2+3:%d",iFont->TextWidthInPixels(temp),iFont->HeightInPixels()*2+3);
    	iPos=TPoint(iConfig.iX,iConfig.iY);
    	// create image and it's mask
    	iBitmap=new(ELeave) CFbsBitmap();
    	iMask=new (ELeave) CFbsBitmap();

    	iBitmap->Create(iSize,EColor16M);
    	iMask->Create(iSize,EColor16M);

    	CFbsBitmapDevice* BitDevice=CFbsBitmapDevice::NewL(iBitmap);
    	CFbsBitmapDevice* MaskDevice=CFbsBitmapDevice::NewL(iMask);

    	BitDevice->CreateContext(iBitGc);
    	MaskDevice->CreateContext(iMaskGc);

    	iBitGc->UseFont(iFont);
    	iMaskGc->UseFont(iFont);
    	//create window group with high priority (always at front)
    	iWg=new (ELeave) RWindowGroup(iWs);
    	iWg->Construct(reinterpret_cast<TUint32>(&iWg));
    	iWg->EnableReceiptOfFocus(EFalse);
    	iWg->SetOrdinalPosition(0, ECoeWinPriorityAlwaysAtFront);
    	//create sprite
    	iSprite= new (ELeave) RWsSprite(iWs);
    	iSprite->Construct(*iWg,iPos,0);
    	iMember.iBitmap=NULL; // no image
    	iMember.iMaskBitmap=NULL;
    	iMember.iOffset=TPoint(0,0);
    	iMember.iInterval=TTimeIntervalMicroSeconds32(0);
    	iMember.iInvertMask=ETrue; // black - not transparadent, white - transparadent
    	iSprite->AppendMember(iMember);
    	iSprite->SetPosition(iPos);

    	iSprite->Activate();
    	iWs.Flush();
    	Draw(iOldName);
    	Hide();

    }