Example #1
0
static void print_dline(hFILE *f, char *key, digest_line_t *dline, int p)
{
    hputs(key, f); hputc('\t',f); 
    hputs((p ? "pass": "******"), f); hputc('\t',f);
    hputi(dline->count[p], f); hputc('\t',f);
    hputc('\t',f);
    hputs(dformat(dline->chksum[0][p]), f); hputc('\t',f);
    hputs(dformat(dline->chksum[1][p]), f); hputc('\t',f);
    hputs(dformat(dline->chksum[2][p]), f); hputc('\t',f);
    hputs(dformat(dline->chksum[3][p]), f); hputc('\n',f);
}
Example #2
0
void
dinfo(loc_t *loc, const char *fmt, ...) {
	va_list ap;
	va_start(ap, fmt);
	dformat(loc, "\033[32;1minfo:\033[0m ", fmt, ap);
	va_end(ap);
}
Example #3
0
void ServiceTask::storeSessionAttributes(HttpResponse* res, HttpRequest* req, const long& sessionTimeout, const bool& sessatserv)
{
	bool sessionchanged = !req->hasCookie();
	sessionchanged |= req->getSession()->isDirty();

	if(sessionchanged)
	{
		std::map<std::string,std::string> vals = req->getSession()->getSessionAttributes();
		std::string prevcookid = req->getCookieInfoAttribute("FFEADID");

		std::string values;
		//logger << "session object modified " << vals.size() << std::endl;
		Date date(true);
		std::string id = CastUtil::lexical_cast<std::string>(Timer::getCurrentTime());
		//int seconds = sessionTimeout;
		date.updateSeconds(sessionTimeout);
		DateFormat dformat("ddd, dd-mmm-yyyy hh:mi:ss");
		std::map<std::string,std::string>::iterator it;

		/*if(sessatserv)
		{
			if(prevcookid=="")
			{
				res->addCookie("FFEADID=" + id + "; expires="+dformat.format(date)+" GMT; path=/; HttpOnly");
			}
			else
			{
				id = prevcookid;
			}
		}*/
		if(!sessatserv || (sessatserv && !ConfigurationData::getInstance()->coreServerProperties.sessservdistocache))
		{
			for(it=vals.begin();it!=vals.end();it++)
			{
				std::string key = it->first;
				std::string value = it->second;
				StringUtil::replaceAll(key,"; ","%3B%20");
				StringUtil::replaceAll(key,"=","%3D");
				StringUtil::replaceAll(value,"; ","%3B%20");
				StringUtil::replaceAll(value,"=","%3D");
				//logger << it->first << " = " << it->second << std::endl;
				if(!sessatserv)
					res->addCookie(key + "=" + value + "; expires="+dformat.format(date)+" GMT; path=/; HttpOnly");
				else
				{
					values += key + "=" + value + "; ";
				}
			}
		}
		/*if(req->getSession()->isDirty())
		{
#ifdef INC_DSTC
			if(ConfigurationData::getInstance()->coreServerProperties.sessservdistocache)
				saveSessionDataToDistocache(id, vals);
			else
#endif
				saveSessionDataToFile(id, values);
		}*/
	}
}
Example #4
0
void
derror(loc_t *loc, const char *fmt, ...) {
	va_list ap;
	va_start(ap, fmt);
	dformat(loc, "\033[31;1merror:\033[0m ", fmt, ap);
	va_end(ap);
	exit(1);
}
Example #5
0
 std::string delaytime_string(time_t seconds)
 {
   unsigned minutes = (unsigned)seconds / 60;
   seconds %= 60;
   unsigned hours = minutes / 60;
   minutes %= 60;
   unsigned days = hours / 24;
   hours %= 24;
   unsigned weeks = days / 7;
   days %= 7;
   std::string result;
   if (weeks > 0)
     result += dformat("%dw ",weeks);
   if (!result.empty() || days > 0)
     result += dformat("%dd ", days);
   if (!result.empty() || hours > 0)
     result += dformat("%d:", hours);
   if (!result.empty() || minutes > 0)
   {
     if (!result.empty())
       result += dformat("%02d:", minutes);
     else
       result += dformat("%d:", minutes);
   }
   if (!result.empty())
     result += dformat("%02d:", seconds);
   else
     result += dformat("%ds", seconds);
   return result;
 }
Example #6
0
void ServiceTask::createResponse(HttpResponse &res,bool flag,map<string,string> vals,string prevcookid, long sessionTimeout, bool sessatserv)
{
	if(flag)
	{
		string values;
		logger << "session object modified " << vals.size() << endl;
		Date date;
		string id = CastUtil::lexical_cast<string>(Timer::getCurrentTime());
		int seconds = sessionTimeout;
		date = date.addSeconds(sessionTimeout);
		DateFormat dformat("ddd, dd-mmm-yyyy hh:mi:ss");
		map<string,string>::iterator it;
		for(it=vals.begin();it!=vals.end();it++)
		{
			string key = it->first;
			string value = it->second;
			StringUtil::replaceAll(key,"; ","%3B%20");
			StringUtil::replaceAll(key,"=","%3D");
			StringUtil::replaceAll(value,"; ","%3B%20");
			StringUtil::replaceAll(value,"=","%3D");
			logger << it->first << " = " << it->second << endl;
			if(!sessatserv)
				res.addCookie(key + "=" + value + "; expires="+dformat.format(date)+" GMT; path=/; HttpOnly");
			else
			{
				values += key + "=" + value + "; ";
			}
		}
		if(sessatserv)
		{
			if(values!="")
			{
				if(prevcookid!="")
					writeToSharedMemeory(prevcookid,values,true);
				else
				{
					writeToSharedMemeory(id,values,false);
					res.addCookie("FFEADID=" + id + "; expires="+dformat.format(date)+" GMT; path=/; HttpOnly");
				}
			}
		}
	}
}
Example #7
0
/*
 *  format the inode blocks
 */
int
iformat(Icache *ic, int f, uint32_t nino, char *name, int bsize,
	int psize)
{
	int nib;
	uint32_t bno, i2b, i;
	Bbuf *bb;
	Dinode *bi;

	/*
	 *  first format disk allocation
	 */
	if(dformat(ic, f, name, bsize, psize) < 0)
		return -1;

	fprint(2, "formatting inodes\n");

	i2b = (bsize - sizeof(Dihdr))/sizeof(Inode);
	nib = (nino + i2b - 1)/i2b;

	for(bno = ic->nab; bno < ic->nab + nib; bno++){
		if(dalloc(ic, 0) == Notabno){
			fprint(2, "iformat: balloc failed\n");
			return -1;
		}
		bb = bcalloc(ic, bno);
		if(bb == 0){
			fprint(2, "iformat: bcalloc failed\n");
			return -1;
		}
		bi = (Dinode*)bb->data;
		bi->magic = Imagic;
		bi->nino = nino;
		for(i = 0; i < i2b; i++)
			bi->inode[i].inuse = 0;
		bcmark(ic, bb);
	}

	bcsync(ic);

	return iinit(ic, f, psize, name);
}
Example #8
0
 std::string timer::text(void) const
 {
   return dformat("%4.2fs CPU, %s elapsed", cpu(), delaytime_string(time(0)-m_time).c_str());
 }