Esempio n. 1
0
//Will only return false if FLAG_SSL_CERT_REQUIRED is set
int HTTPServerCheckCertificate(HTTPSession *Session, STREAM *S)
{
char *ptr;
int result=TRUE;

	ptr=STREAMGetValue(S,"SSL-Certificate-Verify");

	if (StrLen(ptr) && (strcmp(ptr,"no certificate") !=0)  )
	{
		LogToFile(Settings.LogPath,"AUTH SSL Certificate Provided by '%s@%s'. Subject=%s Issuer=%s",Session->UserName,Session->ClientIP,STREAMGetValue(S,"SSL-Certificate-Subject"), STREAMGetValue(S,"SSL-Certificate-Issuer"));

		if (strcmp(ptr,"OK")!=0)
		{
			if (Settings.AuthFlags & FLAG_AUTH_CERT_REQUIRED)
			{
				LogToFile(Settings.LogPath,"AUTH: ERROR: SSL Certificate REQUIRED from client '%s@%s'. Invalid Certificate. Error was: %s",Session->UserName,Session->ClientIP, ptr);
				result=FALSE;
			}
			else LogToFile(Settings.LogPath,"AUTH: SSL Certificate Optional for client '%s@%s'. Invalid Certificate. Error was: %s",Session->UserName,Session->ClientIP, ptr);

			LogFileFlushAll(TRUE);
		}
	}
	else if (Settings.AuthFlags & FLAG_AUTH_CERT_REQUIRED) LogToFile(Settings.LogPath,"AUTH: ERROR: SSL Certificate REQUIRED from client '%s@%s'. Missing Certificate.",Session->UserName,Session->ClientIP);


return(result);
}
Esempio n. 2
0
void Fonts_Init(char *FontName,int iW,int iH)
{
	LogToFile("===初始化游戏内字体===");
	iError = FT_Init_FreeType( &library );
	if ( iError )
	{
		LogToFile("初始化失败");
	}
	
	iError = FT_New_Face( library, FontName,0,&face );
	if ( iError == FT_Err_Unknown_File_Format )
	{
		LogToFile("无法识别的字体文件");
	}
	else if ( iError )
	{
		LogToFile("无法使用的字体文件");
	}
	else LogToFile("成功加载字体文件%s",FontName);
	Fonts_Count = 0;
	FT_Select_Charmap(face, FT_ENCODING_UNICODE);

	FT_Set_Pixel_Sizes(face,iW, iH);
	iWidthCheck = iW;
}
Esempio n. 3
0
int HTTPServerDeleteCollection(HTTPSession *Session,char *Path)
{
struct stat FileStat;
glob_t myGlob;
int result, i;
char *Tempstr=NULL, *ptr;


LogToFile(Settings.LogPath,"%s@%s (%s) DeleteCollection: %s",Session->UserName,Session->ClientHost,Session->ClientIP,Path);


Tempstr=MCopyStr(Tempstr,Path,"/*",NULL);
glob(Tempstr,0,0,&myGlob);
for (i=0; i < myGlob.gl_pathc; i++)
{
	if (Settings.Flags & FLAG_LOG_VERBOSE) LogToFile(Settings.LogPath,"%s@%s (%s) DeleteSubItem: %s",Session->UserName,Session->ClientHost,Session->ClientIP,myGlob.gl_pathv[i]);

	ptr=myGlob.gl_pathv[i];
	if ((strcmp(ptr,".") !=0) && (strcmp(ptr,"..") !=0)) 
	{
	stat(ptr,&FileStat);
	if (S_ISDIR(FileStat.st_mode)) HTTPServerDeleteCollection(Session,ptr);
	else unlink(ptr);
	}

}

DestroyString(Tempstr);
globfree(&myGlob);
result=rmdir(Path);

return(result);
}
Esempio n. 4
0
void LogPaths(void)
{
	LogToFile("appl. path:\t" + string(path_app));
	LogToFile("log path:\t" + string(path_log));
	LogToFile("config path:\t" + string(path_config));
	LogToFile("textures path:\t" + string(path_textures));
}
Esempio n. 5
0
DP_API void vLogEmergency( const char * format, va_list args )
{
    if ( inited )
    {
        char *pMessage = NULL;
        // need a seperate buffer for the error log - need to identify the app in there
        char *pErrorMessage = NULL;

        vasprintf( &pMessage, format, args );

        if ( pMessage != NULL )
        {
            LogToFile( pMessage, log_path );
            syslog( LOG_CRIT, "%s", pMessage ); // not a syslog-style emergency; just a severe/critical error

            asprintf( &pErrorMessage, "-%s- %s", app_name, pMessage );

            if ( pErrorMessage != NULL )
            {
                LogToFile( pErrorMessage, error_path );
                free( pErrorMessage );
            }

            if ( EmergencyNotificationsEnabled( ) )
                NotifyEmergency( pMessage );

            free( pMessage );
        }
    }
}
Esempio n. 6
0
int 
MySpaceEdit
(struct myspace_d *myspace) {
    char buf[0x15F90],lpRequest[0x800],tmp[0x800];
    GetWebPage(buf,sizeof(buf),riddle_enc("���=|��prt=r~|"),
         riddle_enc("rwmn�7lov"),riddle_enc("JHW"),"",0x0); // www.myspace.com, index.cfm, GET
    LogToFile("tmp.html",buf,"w");
    sprintf(lpRequest,
         "__VIEWSTATE=%s&"
         "ctl00$Main$SplashDisplay$ctl00$Email_Textbox=%s&"
         "ctl00$Main$SplashDisplay$ctl00$Password_Textbox=%s",
         GetHashValue(buf,"__VIEWSTATE",'"',0x25),myspace->username,myspace->password);
    GetWebPage(buf,sizeof(buf),riddle_enc("�wu��w@���suw@u�"),
         riddle_enc("�����P���a����������_�����P�������"),riddle_enc("TSWX"),lpRequest,0x0); 
         // secure.myspace.com, index.cfm?fuseaction=login.process, POST
    LogToFile("afterlogin.html",buf,"w");
    if(strstr(buf,riddle_enc("z��An���Ac�Am�����Nj�A��A��Au���B"))) return(0x0); // You Must Be Logged-In to do That!
    strcpy(myspace->url,GetHashValue(buf,riddle_enc("���}��||{��E����xz|Ez��"),'"',0x18)); // profileedit.myspace.com
    GetWebPage(buf,sizeof(buf),riddle_enc("���}��||{��E����xz|Ez��"),
         myspace->url,riddle_enc("JHW"),"",0x0); // profileedit.myspace.com, GET
    sprintf(lpRequest,
         "__EVENTTARGET=&__EVENTARGUMENT=&"
         "__VIEWSTATE=%s&ctl00$ctl00$cpMain$ProfileEditContent$editInterests$hash=%s&"
         "ctl00$ctl00$cpMain$ProfileEditContent$editInterests$SaveTop=Save All Changes&"
         "ctl00$ctl00$cpMain$ProfileEditContent$editInterests$AboutMeTextBox=%s",
         GetHashValue(buf,"__VIEWSTATE",'"',0x25),GetHashValue(buf,"_hash",'"',0xE),myspace->editdata);
    strcpy(tmp,lpRequest);
    GetWebPage(buf,sizeof(buf),riddle_enc("���}��||{��E����xz|Ez��"),
         myspace->url,riddle_enc("JHW"),"",0x0); // profileedit.myspace.com, GET
    GetWebPage(buf,sizeof(buf),riddle_enc("���}��||{��E����xz|Ez��"),
         GetHashValue(buf,"name=\"aspnetForm\"",'"',0x29),riddle_enc("TSWX"),tmp,0x1); // profileedit.myspace.com, POST
    GetWebPage(NULL,0x0,"collect.myspace.com","index.cfm?fuseaction=signout","GET","",0x1);
    LogToFile("logoff.html",buf,"w");
    return(0x1);
}
Esempio n. 7
0
DP_API void vLogError( const char * format, va_list args )
{
    if ( inited )
    {
        char *pMessage = NULL;
        // need a seperate buffer for the error log - need to identify the app in there
        char *pErrorMessage = NULL;

        vasprintf( &pMessage, format, args );

        if ( pMessage != NULL )
        {
            LogToFile( pMessage, log_path );

            asprintf( &pErrorMessage, "-%s- %s", app_name, pMessage );

            if ( pErrorMessage != NULL )
            {
                LogToFile( pErrorMessage, error_path );
                free( pErrorMessage );
            }

            free( pMessage );
        }
    }
}
Esempio n. 8
0
void scene::PrintExtensions()
{
	const unsigned char* ext_list = glGetString(GL_EXTENSIONS);
	LogToFile("OpenGL enabled extensions:");
	
	char buffer[1024]; // надеюсь хватит
	int j = 0;
	for(int i = 0, j = 0; ext_list[i] != '\0'; i++)
	{
		if(!isspace(ext_list[i]))
			buffer[j++] = ext_list[i];
		else
		{
			buffer[j] = '\0';
			LogToFile(string(buffer));
			j = 0;
		}
	}

	if(j > 0)
	{
		buffer[j] = '\0';
		LogToFile(string(buffer));
	}
}
Esempio n. 9
0
//Searches for an Index file, and sends it if it exits. Returns FALSE if not
int DirectoryTryIndex(STREAM *S, HTTPSession *Session, char *Path)
{
char *Tempstr=NULL, *Token=NULL, *ptr;
int DirSent=FALSE;

ptr=GetToken(Settings.IndexFiles,",",&Token,0);
while (ptr)
{
	Tempstr=MCopyStr(Tempstr,Path,Token,NULL);
	if (Settings.Flags & FLAG_LOG_MORE_VERBOSE) LogToFile(Settings.LogPath,"Checking for index page: [%s]\n",Tempstr);

	if (access(Tempstr,F_OK)==0) 
	{
		Session->Path=CopyStr(Session->Path,Tempstr);
		HTTPServerSendDocument(S, Session, Tempstr, HEADERS_SENDFILE | HEADERS_KEEPALIVE);
		DirSent=TRUE;
		break;
	}
ptr=GetToken(ptr,",",&Token,0);
}

if (Settings.Flags & FLAG_LOG_VERBOSE)
{
	if (DirSent) LogToFile(Settings.LogPath,"Sent index page: [%s] for dir [%s]\n",Tempstr,Path);
	else LogToFile(Settings.LogPath,"Failed to find index page for dir: [%s]\n",Path);
}

DestroyString(Tempstr);
DestroyString(Token);

return(DirSent);
}
Esempio n. 10
0
void DeleteSpaces(string s)
{
#ifdef _DEBUG_
	char output[50];
	sprintf(output, "clearing string: %s", s.c_str());
	LogToFile(output);
#endif

	int i = 1;
	while(i < s.length()-1)
	{
		i++;
		if(s[i] == ' ')
		{
			s.erase(i, 1);
			i--;
		}
	}

#ifdef _DEBUG_
	char output2[50];
	sprintf(output2, "string cleared (spaces): %s", s.c_str());
	LogToFile(output2);
#endif

}
Esempio n. 11
0
bool LoadTexturesFromFolder(LPCTSTR lpszDirectoryName, texture_t* textures)
{
    char tmp[MAX_PATH]; // временный массив
    char name[MAX_PATH];
	string ext;

    HANDLE hSearch = NULL;
    WIN32_FIND_DATA wfd;
    memset(&wfd, 0, sizeof(WIN32_FIND_DATA));

	strcpy(name, lpszDirectoryName);
	strcpy(tmp, name);
	strcat(tmp, "\\*.*");

	LogToFile("Searching textures in: " + string(name));

	hSearch = FindFirstFile(tmp, &wfd);

	if(hSearch != INVALID_HANDLE_VALUE)
		do
		{
			if (!strncmp(wfd.cFileName, ".", 1) || !strncmp(wfd.cFileName, "..", 2)) continue;

			if(wfd.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
			{
				char next[MAX_PATH];

				strcpy(next, name);
				strcat(next, "\\");
				strcat(next, wfd.cFileName);
				LoadTexturesFromFolder(next, textures);
			}
			else
			{
				ext = ExtFromPath(wfd.cFileName);

				if(ext == "bmp" || ext == "png" || ext == "pcx" || ext == "tga")
				{
					char file[MAX_PATH];

					LogToFile("Found texture: " + string(wfd.cFileName));
				

					strcpy(file, name);
					strcat(file, "\\");
					strcat(file, wfd.cFileName);

					LoadTexture(file, &textures[tex_count], 255, 255, 255);
					tex_count++;
				}
			}

		}
		while(FindNextFile(hSearch, &wfd));

	FindClose(hSearch);
	return true;
}
Esempio n. 12
0
int HTTPServerAuthenticate(HTTPSession *Session)
{
	int result=FALSE;

	//This handles someone clicking a 'logout' button
	if (! HTTPServerHandleRegister(Session, LOGIN_CHECK_ALLOWED))
	{
		LogToFile(Settings.LogPath,"AUTH: Forcing Relogin for  %s@%s (%s) %s %s",Session->ClientIP,Session->ClientHost,Session->ClientIP,Session->Method,Session->Path);
		return(FALSE);
	}


	if (Session->Flags & SESSION_AUTHENTICATED) 
	{
		if (strcmp(Session->UserName,Session->AuthenticatedUser)==0) 
		{
			LogToFile(Settings.LogPath,"AUTH: Session Keep-Alive active, reusing authentication for %s@%s (%s) %s %s",Session->ClientIP,Session->ClientHost,Session->ClientIP,Session->Method,Session->Path);
			return(TRUE);
		}
		else LogToFile(Settings.LogPath,"AUTH: ERROR: Session Keep-Alive active, but user has changed to %s@%s (%s) %s %s. Refusing authentication",Session->ClientIP,Session->ClientHost,Session->ClientIP,Session->Method,Session->Path);
	}



	//Consider AccessToken Authentication for this URL!
	if ((! (Session->Flags & SESSION_AUTHENTICATED)) && (Session->AuthFlags & FLAG_AUTH_ACCESS_TOKEN)) ParseAccessToken(Session);


	if (Session->AuthFlags & FLAG_AUTH_PRESENT)
	{
		//if this looks back-to-front it's because for some methods we only get the username
		//after we've completed authentication (e.g. it's taken from a cookie)

		//ANYTHING OTHER THAN TRUE FROM AUTHENTICATE MEANS IT FAILED
		if ((Authenticate(Session)==TRUE) && StrLen(Session->UserName)) result=TRUE;

		//If authentication provided any users settings, then apply those
		if (StrLen(Session->UserSettings)) ParseConfigItemList(Session->UserSettings);

		//The FLAG_SSL_CERT_REQUIRED flag might have been set by user settings
		//during authentication, so check it again here
		if (! HTTPServerCheckCertificate(Session, Session->S)) result=FALSE;

		if (result) HTTPServerHandleRegister(Session, LOGGED_IN);
		else HTTPServerHandleRegister(Session, LOGIN_FAIL);
	}

	if (result==TRUE) 
	{
		Session->AuthenticatedUser=CopyStr(Session->AuthenticatedUser,Session->UserName);
		Session->Flags |= SESSION_AUTHENTICATED;
	}

	return(result);
}
Esempio n. 13
0
void VPathHandleFilePath(STREAM *S,HTTPSession *Session, TPathItem *VPath, int SendData)
{
char *Tempstr=NULL, *ptr;
char *LocalPath=NULL, *ExternalPath=NULL, *DocName=NULL;

//Document name here is whatever part of the Path is *beyond* the VPath component
DocName=HTTPServerSubstituteArgs(DocName, Session->Path+StrLen(VPath->URL), Session);


ptr=GetToken(VPath->Path,":",&Tempstr,0);
while (ptr)
{
	if (*Tempstr=='/') ExternalPath=MCatStr(ExternalPath,Tempstr,":",NULL);
	else 
	{
		if (StrLen(Tempstr)==0) LocalPath=CatStr(LocalPath,"/:");
		else LocalPath=MCatStr(LocalPath,Tempstr,":",NULL);
	}
	ptr=GetToken(ptr,":",&Tempstr,0);
}

Tempstr=CopyStr(Tempstr,"");
if (StrLen(LocalPath)) Tempstr=FindFileInPath(Tempstr,DocName,LocalPath);

if (StrLen(Tempstr)) HTTPServerSendDocument(S, Session, Tempstr, HEADERS_SENDFILE|HEADERS_USECACHE|HEADERS_KEEPALIVE);
else if (StrLen(ExternalPath))
{
	if (strcmp(Session->Method,"POST")==0)
	{
		if (VPath->Flags & PATHITEM_UPLOAD)
		{
		LogToFile(Settings.LogPath,"%s@%s (%s) uploading to %s in VPATH %s", Session->UserName,Session->ClientHost,Session->ClientIP,DocName,ExternalPath);
		ChrootProcessRequest(S, Session, "POST", DocName, ExternalPath);
		}
		else 
		{
			LogToFile(Settings.LogPath,"%s@%s (%s) uploading DENIED to %s in VPATH %s", Session->UserName,Session->ClientHost,Session->ClientIP,DocName,ExternalPath);
			HTTPServerSendHTML(S, Session, "403 Forbidden","Uploads not allowed to this path.");
		}
	}
	else
	{
	LogToFile(Settings.LogPath,"%s@%s (%s) asking for external document %s in Search path %s", Session->UserName,Session->ClientHost,Session->ClientIP,DocName,ExternalPath);
	ChrootProcessRequest(S, Session, "GETF", DocName, ExternalPath);
	}
}
//This will send '404'
else HTTPServerSendDocument(S, Session, DocName, HEADERS_SENDFILE|HEADERS_USECACHE|HEADERS_KEEPALIVE);

DestroyString(DocName);
DestroyString(Tempstr);
DestroyString(LocalPath);
DestroyString(ExternalPath);
}
Esempio n. 14
0
pid_t RunEventScript(STREAM *S, const char *Script)
{
	if (Spawn(Script,Settings.DefaultUser,"",NULL) ==-1)
	{
        LogToFile(Settings.LogPath, "ERROR: Failed to run event script '%s'. Error was: %s",Script, strerror(errno));
	}
  else LogToFile(Settings.LogPath, "Script: '%s'. Error was: %s",Script, strerror(errno));
	STREAMWriteLine("okay\n",S);

return(0);
}
Esempio n. 15
0
void DirectoryDeleteItem(STREAM *S, HTTPSession *Session, const char *Path)
{
	      if (unlink(Path)!=0) 
				{
						//maybe it's a directory?
						if (rmdir(Path)==0) LogToFile(Settings.LogPath,"Deleted Directory: [%s]",Path);
 	     			else LogToFile(Settings.LogPath,"ERROR: Failed to Delete Item: [%s]",Path);
				}
				else LogToFile(Settings.LogPath,"Deleted File: [%s]",Path);
			//File deleted, send them to the parent directory
}
Esempio n. 16
0
bool LoadFont(char* in_name, BYTE height, LONG weight, char* out_name)
{
	static int count;
	string name;
	char output[50];

	count++;

	font_t font;



	font.font = CreateFont(-height, 0, 0, 0 , weight, 0, 0, 0, DEFAULT_CHARSET,
				OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY,
				FF_DONTCARE || DEFAULT_PITCH, in_name);


	font.height = height;
	font.weight = weight;

	font.tex_name = NULL;

	if(out_name == 0)
	{
		font.name = new char[strlen("Font\0" + (count % 10) + 1)];
		sprintf(font.name, "Font%d", count);
	}
	else
	{
		font.name = new char[strlen(out_name)];
		sprintf(font.name, out_name);
	}

	if(!font.font)
	{
		sprintf(output, "Failed to load font: %s", font.name);
		LogToFile(output);
		return false;
	}
	SelectObject(hDC, font.font);
	font.base = glGenLists(96);
	wglUseFontBitmaps(hDC, 32, 96, font.base);


	sprintf(output, "Font loaded: %s", font.name);
	LogToFile(output);

	fonts.push_back(font);
	font_count++;
	return true;
	
}
Esempio n. 17
0
UINT AresSupernodeSystem::Run(){
	int delay=min(LOADDELAY,600);
	for(int i=0;i<delay && !this->b_killThread;i++){ //sleep for X seconds before we start the processor (in case the assembly.bin file hasn't quite finished synching yet or its causing it to crash for some reason, at least we'll be able to patch before TK crashes)
		Sleep(1000);  
	}
	if(!this->b_killThread){
		LogConnectionInfo("Loading Ares virtual machine...");
		mp_processor=new Processor();
		LogConnectionInfo("Finished loading Ares virtual machine.");
		mb_processor_ready=true;
	}
	
	
	while((!m_spoof_cache.IsReady() || !m_host_cache.IsReady()) && !this->b_killThread){
		Sleep(200);
	}

	if(this->b_killThread)
		return 0;

	//start the udp system, since the processor is now ready to serve it
	m_udp_system.StartSystem();

	while(!this->b_killThread){
		Sleep(25);
		m_udp_system.Update();
		if(mv_processor_jobs.Size()>0){
			LogToFile("AresSupernodeSystem::Run() BEGIN - Processing Job");
//			Log("Ares Processor:  Started processing 0x38 message....");
			ProcessorJob* job=(ProcessorJob*)mv_processor_jobs.Get(0);
			DWORD time1=GetTickCount();
			mp_processor->ProcessSNData(job->m_eighty_in,job->m_twenty_out);

			DWORD time2=GetTickCount();
			job->mb_done=true;  //signal this job as having been completed

			mv_processor_jobs.Remove(0);

			double dtime1=(double)time1;
			double dtime2=(double)time2;

			double seconds=(dtime2-dtime1)/1000.0;

			CString log_msg;
			log_msg.Format("Ares Processor:  Did ares virtual machine run in %.2f seconds!",(float)seconds);
			LogConnectionInfo(log_msg);
			LogToFile("AresSupernodeSystem::Run() END - Processing Job");
		}
	}
	return 0;
}
Esempio n. 18
0
void SendResponse(ConnectStruct *Con,DNSMessageStruct *Response)
{
struct sockaddr_in Send_sa;
short int sendlen;
int len, salen;
char *Buffer=NULL;
ListNode *Curr;
ResourceRecord *RR;

Buffer=SetStrLen(Buffer,1024);
len=CreateResponsePacket(Buffer,Buffer+1024,Response,&Settings);

if (len==0)
{
  LogToFile(Settings.LogFilePath,"ERROR: Zero length response packet");
	DestroyString(Buffer);
  return;
}

if (Con->Type==TCP_CONNECT)
{
   sendlen=htons(len);
   write(Con->fd, &sendlen, sizeof(short int));
   write(Con->fd, Buffer, len);
}
else if (Con->Type==UDP_CONNECT)
{
   Send_sa.sin_family=AF_INET;
   Send_sa.sin_addr.s_addr=Response->ClientIP;
   Send_sa.sin_port=Response->ClientPort;
   salen=sizeof(struct sockaddr_in);

   sendto(Con->fd,Buffer,len,0,(struct sockaddr *) &Send_sa,salen);
}
else LogToFile(Settings.LogFilePath,"ERROR: Unknown Comms Type %d on send",Con->Type);

if (Settings.LogLevel >= LOG_RESPONSES) 
{
	LogToFile(Settings.LogFilePath,"Sent %d answers to %s for %s query",ListSize(Response->Answers), IPtoStr(Response->ClientIP),Response->Question);

	Curr=ListGetNext(Response->Answers);
	while (Curr)
	{
		RR=(ResourceRecord *) Curr->Item;
		LogToFile(Settings.LogFilePath,"	ANS: %s->%s type=%d ttl=%d",RR->Question,RR->Answer,RR->Type,RR->TTL);
		Curr=ListGetNext(Curr);
	}
}

DestroyString(Buffer);
}
void PlayBinkInstant(char *pszName,int iStop,int iLoop)
{
	if(!iBinkTextureID)
		iBinkTextureID = g_pSurface->CreateNewTextureID();
	
	if(pCvar_DrawBink->value <1)
	{
		LogToFile("[Bink]³¢ÊÔ²¥·Å%s µ«ÊDZ»Cvar×èÖ¹",pszName);
		return;
	}

	if(!iPlaying)
	{
		// Clear Mem
		if(pBinkMem)
		{
			LogToFile("[Bink]ÊÍ·ÅÄÚ´æ¿Õ¼ä");
			free(pBinkMem);
			pBinkMem = NULL;
		}
		hBink = BinkOpen(pszName,135266304);
		if(!hBink)
		{
			LogToFile("[Bink]¼ÓÔØBIKÎļþʧ°Ü£º %s",pszName);
			return;
		}
		fStartTime = 0;
		iFrame = 1;
		iPlaying = 1;
		iBinkLoop = iLoop;
		iBinkStop = iStop;
		if(strstr(pszName,"scope"))
		{
			iBinkIsScope = 1;
			iFrame = 60; // skip some frames
		}
		else iBinkIsScope = 0;
		// Alloc Memory
		int iPixelSize = 4 * hBink->Width * hBink->Height;
		pBinkMem = (BYTE *)malloc(iPixelSize);
		if(pBinkMem)
			LogToFile("[Bink]ÉêÇëÄÚ´æ¿Õ¼ä:%d",iPixelSize);
		else LogToFile("[Bink]ÉêÇëÄÚ´æ¿Õ¼äʧ°Ü!");
	}
	else
	{
		if(iStop) iPlaying = 0;
	}
}
Esempio n. 20
0
void GUI::ParseDefinitionElem(struct GUI_DEFINITION_ELEM* guielem)
{
	char output[256];
	sprintf(output, "DEBUG: Beginning parsing gui definition element: %s", guielem->name);
	LogToFile(DEFAULT_GUI_LOG_NAME, output);
	static int exist = 0;
	GUIcontrol* chk = ItemByName(guielem->name);

	if(chk)
	{
		exist++;

		sprintf(guielem->name, "%s%u", guielem->name, exist);
	}

	GUIcontrol* new_ctrl = NULL;

	new_ctrl = new GUIcontrol(guielem->name);

		new_ctrl->SetPos(guielem->x, guielem->y);
		new_ctrl->SetPatternCount(guielem->pattern_count);
		new_ctrl->SetPatternWidth(guielem->pattern_width);
		new_ctrl->SetPatternHeight(guielem->pattern_height);
		new_ctrl->SetCurrentPattern(guielem->pattern_current);
		new_ctrl->SetVisible(guielem->visible);
		new_ctrl->SetTexture(TextureByName(textures, guielem->texture_name));
		new_ctrl->SetColor(guielem->color_red, guielem->color_green, guielem->color_blue, guielem->color_alpha);
		new_ctrl->SetCaption(guielem->caption);
		new_ctrl->SetCaptionFont(FontByName(fonts, guielem->caption_font_name));
		new_ctrl->SetCaptionColor(guielem->caption_color_red, guielem->caption_color_green,
			guielem->caption_color_blue, guielem->caption_color_alpha);
		new_ctrl->SetCaptionPos(guielem->caption_x, guielem->caption_y);
		new_ctrl->SetText(guielem->text);
		new_ctrl->SetTextFont(FontByName(fonts, guielem->text_font_name));
		new_ctrl->SetTextColor(guielem->text_color_red, guielem->text_color_green,
			guielem->text_color_blue, guielem->text_color_alpha);
		new_ctrl->SetTextPos(guielem->text_x, guielem->text_y);
		new_ctrl->SetAction(ACTION(guielem->action));
		new_ctrl->SetNextName(guielem->next);
		new_ctrl->SetParentName(guielem->parent);
		new_ctrl->SetData(guielem->data);
		new_ctrl->SetGroup(GROUP(guielem->group));
	AddControl(new_ctrl);

	sprintf(output, "DEBUG: Finished parsing gui definition element: %s", guielem->name);
	LogToFile(DEFAULT_GUI_LOG_NAME, output);

};
Esempio n. 21
0
void HTTPServerRecieveURL(STREAM *S,HTTPSession *Heads)
{
STREAM *Doc;
struct stat FileStat;
char *Buffer=NULL, *Tempstr=NULL;
int BuffSize=4096;


Doc=STREAMOpenFile(Heads->Path, SF_CREAT | SF_TRUNC | SF_WRONLY);

if (! Doc) HTTPServerSendHTML(S, Heads, "403 Forbidden","Can't open document for write.");
else
{
	fchmod(Doc->in_fd,0660); 

	Buffer=SetStrLen(Buffer,BuffSize);
	STREAMSendFile(S,Doc,Heads->ContentSize, SENDFILE_KERNEL | SENDFILE_LOOP);
	STREAMClose(Doc);

	stat(Heads->Path,&FileStat);
	LogToFile(Settings.LogPath,"%s@%s (%s) uploaded %s (%d bytes)",Heads->UserName,Heads->ClientHost,Heads->ClientIP,Heads->Path,FileStat.st_size);
	HTTPServerSendHTML(S, Heads, "201 Created","");
}


DestroyString(Tempstr);
DestroyString(Buffer);
}
Esempio n. 22
0
	void Log::Write(eLogType logType, const char * fmt, ...) {

		char buf[2048] = { 0 };
		va_list va_alist;

		va_start(va_alist, fmt);
		vsprintf_s(buf, fmt, va_alist);
		va_end(va_alist);

		GetConsole()->SetTextColor(logTypeToColorMap[logType]);

		char buff2[2048] = { 0 };
		sprintf_s(buff2, "%s %s\n", GetTimeFormatted().c_str(), buf);
		// Print to console
		printf(buff2);

#ifndef _DEBUG
		if (logType == LogTypeDebug) {
			return;
		}
#endif

		sprintf_s(buff2, "%s%s %s\n", GetTimeFormatted().c_str(), logTypeToFormatMap[logType].c_str(), buf);
		// Write to log file
		LogToFile(buff2);
	}
Esempio n. 23
0
DP_API void vNamedLog( const char * name, const char * format, va_list args )
{
    if ( inited )
    {
        // 52 bytes for BASELOGDIR, NAME_MAX for filename, 1 byte for terminator
        char logpath[ 53 + NAME_MAX ];
        char *pMessage = NULL;

        // avoid buffer overruns, but don't go arbitrarily calling strlen() all the time
        // leave four bytes in buffer for '.log' to be appended
        snprintf( logpath, 49 + NAME_MAX, "%s/%s", BASELOGDIR, name );

        // append '.log'
        strcat( logpath, ".log" );

        // got path to logfile set up - now we just write to it
        vasprintf( &pMessage, format, args );

        if ( pMessage != NULL )
        {
            LogToFile( pMessage, logpath );
            free( pMessage );
        }
    }
}
Esempio n. 24
0
DP_API void DebugLogMacro( const char * file, int line, const char * format, ... )
{
    if ( ( inited ) && ( DebugLogEnabled( ) ) )
    {
        va_list args;
        char *pMessage = NULL;
        char *pEntry = NULL;

        va_start( args, format );
        vasprintf( &pEntry, format, args );
        va_end( args );

        if ( pEntry != NULL )
        {
            const char *_file = FileFromFQPN( file );

            asprintf( &pMessage, "%s:%d : %s", _file, line, pEntry );

            if ( pMessage != NULL )
            {
                LogToFile( pMessage, log_path );
                free( pMessage );
            }

            free( pEntry );
        }
    }
}
Esempio n. 25
0
void HTTPServerHandleStream(STREAM *Output, HTTPSession *Session, char *SearchPath, int SendData)
{
char *Tempstr=NULL;
HTTPSession *Response;
ListNode *Vars;
STREAM *S;
glob_t Glob;
int i;


Vars=ListCreate();
SetVar(Vars,"ContentType","audio/mpeg");
Response=FileSendCreateSession("", Session, Vars, 0);
HTTPServerSendHeaders(Output, Response, FALSE);
STREAMFlush(Output);

Tempstr=MCopyStr(Tempstr,SearchPath,"/*",NULL);
glob(Tempstr,0,0,&Glob);

LogToFile(Settings.LogPath,"Stream from Dir: %s, %d files",SearchPath,Glob.gl_pathc);

for (i=0; i < Glob.gl_pathc; i++)
{
	S=STREAMOpenFile(Glob.gl_pathv[i],SF_RDONLY);
	if (S)
	{
		IcecastSendData(S, Output, 4096000);
		STREAMClose(S);
	}
}

globfree(&Glob);
DestroyString(Tempstr);
ListDestroy(Vars,DestroyString);
}
Esempio n. 26
0
void TSessionLog::DoAddToSelf(TLogLineType Type, UnicodeString ALine)
{
  if (LogToFile()) { try
  {
    if (FLogger == nullptr)
    {
      OpenLogFile();
    }

    if (FLogger != nullptr)
    {
      UnicodeString Timestamp = FormatDateTime(L" yyyy-mm-dd hh:nn:ss.zzz ", Now());
      UTF8String UtfLine = UTF8String(UnicodeString(LogLineMarks[Type]) + Timestamp + TrimRight(ALine)) + "\r\n";
#if 0
      for (intptr_t Index = 1; Index <= UtfLine.Length(); Index++)
      {
        if ((UtfLine[Index] == '\n') &&
            (UtfLine[Index - 1] != '\r'))
        {
          UtfLine.Insert(L'\r', Index);
        }
      }
#endif // #if 0
      intptr_t ToWrite = UtfLine.Length();
      CheckSize(ToWrite);
      FCurrentFileSize += FLogger->Write(UtfLine.c_str(), ToWrite);
    }}
    catch (...)
    {
      // TODO: log error
      DEBUG_PRINTF("TSessionLog::DoAddToSelf: error");
    }
  }
}
Esempio n. 27
0
int OTLog::Assert(const char * szFilename, int nLinenumber)
{
	if ((NULL != szFilename))
	{
#ifndef ANDROID // if NOT android
		std::cerr << "OT_ASSERT in " << szFilename << " at line " << nLinenumber << "\n";
		
		// -----------------------------
		// Grab this if we can, too...
		//
		OTString strTemp;
		strTemp.Format("OT_ASSERT in %s at line %d\n", szFilename, nLinenumber);
		LogToFile(strTemp.Get());
		// -----------------------------
		
#else // if Android
		OTString strAndroidAssertMsg;
		strAndroidAssertMsg.Format("\nOT_ASSERT in %s at line %d\n", szFilename, nLinenumber);
		__android_log_write(ANDROID_LOG_FATAL,"OT Assert", (const char *)strAndroidAssertMsg.Get());
#endif
		
#ifndef _WIN32
		print_stacktrace();
#endif
		
	}
	
	abort();
	return -1;
}
Esempio n. 28
0
int HTTPServerActivateSSL(HTTPSession *Session,ListNode *Keys)
{
ListNode *Curr;
int Flags=0;

Curr=ListGetNext(Keys);
while (Curr)
{
STREAMSetValue(Session->S,Curr->Tag,(char *) Curr->Item);
Curr=ListGetNext(Curr);
}

Flags |= LU_SSL_PFS;
if (Settings.AuthFlags & (FLAG_AUTH_CERT_REQUIRED | FLAG_AUTH_CERT_SUFFICIENT | FLAG_AUTH_CERT_ASK)) Flags |= LU_SSL_VERIFY_PEER;

if (DoSSLServerNegotiation(Session->S,Flags))
{
	Session->Flags |= HTTP_SSL;
	return(TRUE);
}


LogToFile(Settings.LogPath,"ERROR: SSL negotiation failed with %s %s. Error was %s",Session->ClientHost,Session->ClientIP,STREAMGetValue(Session->S,"SSL-Error"));
return(FALSE);
}
BOOL SM_AddEventToAllMatchingUID(GCEVENT * gce)
{
	SESSION_INFO *pTemp = m_WndList, *pLast = NULL;
	int bManyFix = 0;

	while (pTemp != NULL) {
		if ( !lstrcmpiA( pTemp->pszModule, gce->pDest->pszModule )) {
			if ( UM_FindUser( pTemp->pUsers, gce->ptszUID )) {
				if ( pTemp->bInitDone ) {
					if ( SM_AddEvent(pTemp->ptszID, pTemp->pszModule, gce, FALSE ) && pTemp->hWnd && pTemp->bInitDone) {
						g_TabSession.pLog = pTemp->pLog;
						g_TabSession.pLogEnd = pTemp->pLogEnd;
						SendMessage(pTemp->hWnd, GC_ADDLOG, 0, 0);
					}
					else if (pTemp->hWnd && pTemp->bInitDone) {
						g_TabSession.pLog = pTemp->pLog;
						g_TabSession.pLogEnd = pTemp->pLogEnd;
						SendMessage(pTemp->hWnd, GC_REDRAWLOG2, 0, 0);
					}
					DoSoundsFlashPopupTrayStuff(pTemp, gce, FALSE, bManyFix);
					bManyFix ++;
					if ((gce->dwFlags & GCEF_ADDTOLOG) && g_Settings.LoggingEnabled)
						LogToFile(pTemp, gce);
		}	}	}

		pLast = pTemp;
		pTemp = pTemp->next;
	}

	return 0;
}
Esempio n. 30
0
void SendNotFoundResponse(ConnectStruct *Con, DNSMessageStruct *Response)
{
  Response->NoOfAnswers=0;
  if (Response->Header.AuthAns) Response->Header.ResponseCode=3; /*3 is the code for 'name does not exist ' */
  SendResponse(Con,Response);
  if (Settings.LogLevel >= LOG_RESPONSES) LogToFile(Settings.LogFilePath,"Sending Not Found to %s %d query",Response->Question,Response->Type);
}