Example #1
0
void ls_switch_file( ChannelLog *cl )
{
	static char tmbuf[MAXPATH];
	static char newfname[MAXPATH];
	static char oldfname[MAXPATH];
	int res;

	/* no need to switch, its not opened */
	if( cl->logfile == NULL  ) return;		
	ls_close_log( cl );
	/* check if the target directory exists */
	if( os_create_dir( LogServ.savedir ) != NS_SUCCESS )
	{
		return;
	}
	os_strftime( tmbuf, MAXPATH, "%d%m%Y%H%M%S", os_localtime( &me.now ) );
	ircsnprintf( newfname, MAXPATH, "%s/%s-%s.log", LogServ.savedir, cl->filename, tmbuf );
	ircsnprintf( oldfname, MAXPATH, "%s/%s.log", LogServ.logdir, cl->filename );
	res = os_rename( oldfname, newfname );
	if( res != 0 ) {
		nlog( LOG_CRITICAL, "Couldn't rename file %s: %s", oldfname, os_strerror() );
		return;
	}	
	nlog( LOG_NORMAL, "Switched Logfile for %s from %s to %s", cl->channame, oldfname, newfname );
}
Example #2
0
void xchat_startlog( ChannelLog *chandata, const CmdParams *cmdparams )
{
	static char startlog[BUFSIZE];
	static char tmbuf[TIMEBUFSIZE];
	
	os_strftime( tmbuf, TIMEBUFSIZE, "%a %b %d %H:%M:%S %Y", os_localtime( &me.now ) );
	ircsnprintf( startlog, BUFSIZE, XSTARTLOG, tmbuf );
	os_fprintf( chandata->logfile, "%s", startlog );
}
Example #3
0
static char *xchat_time( void )
{
	os_strftime( timebuf, TIMEBUFSIZE, XCHATTIME, os_localtime( &me.now ) );
	return timebuf;
}
bool ServerAutomaticArchive::isInArchiveWindow(const std::wstring &window_def)
{
	std::vector<std::wstring> toks;
	Tokenize(window_def, toks, L";");
	bool matched_dom=false;
	for(size_t i=0;i<toks.size();++i)
	{
		if(trim(toks[i])==L"*")
			continue;

		std::vector<std::wstring> stoks;
		Tokenize(toks[i], stoks, L",");

		std::vector<int> nums;
		for(size_t j=0;j<stoks.size();++j)
		{
			int n=watoi(stoks[j]);
			if(i==3)//dow
			{
				if(n==7) n=0;
			}
			nums.push_back(n);
		}

		int ref_num=-1;
		if(i==0) // hour
		{
			ref_num=atoi(os_strftime("%H").c_str());
		}
		else if(i==1) // dom
		{
			ref_num=atoi(os_strftime("%d").c_str());
		}
		else if(i==2) // mon
		{
			ref_num=atoi(os_strftime("%m").c_str());
		}
		else if(i==3) // dow
		{
			ref_num=atoi(os_strftime("%w").c_str());
			if(ref_num==7) ref_num=0;
		}

		if( std::find(nums.begin(), nums.end(), ref_num)==nums.end() )
		{
			if(i!=1)
			{
				if(i==3 && matched_dom==true)
					continue;

				return false;
			}
		}
		else
		{
			if(i==1) matched_dom=true;
		}
	}

	return true;
}