Example #1
0
void
O2IMDB_SAX2Handler::
endElement(const XMLCh* const uri
		 , const XMLCh* const localname
		 , const XMLCh* const qname)
{
	switch (CurElm) {
		case IM_XMLELM_IP:
			CurIM->ip = e2ip(buf.c_str(), buf.size());
			break;
		case IM_XMLELM_PORT:
			CurIM->port = (ushort)wcstoul(buf.c_str(), NULL, 10);
			break;
		case IM_XMLELM_ID:
			CurIM->id.assign(buf.c_str(), buf.size());
			break;
		case IM_XMLELM_PUBKEY:
			CurIM->pubkey.assign(buf.c_str(), buf.size());
			break;
		case IM_XMLELM_NAME:
			CurIM->name = buf;
			break;
		case IM_XMLELM_DATE:
			CurIM->date = datetime2time_t(buf.c_str(), buf.size());
			break;
		case IM_XMLELM_MSG:
			CurIM->msg = buf;
			break;
		case IM_XMLELM_KEY:
			CurIM->key.assign(buf.c_str(), buf.size());
			break;
		case IM_XMLELM_MINE:
			CurIM->mine = buf[0] == L'0' ? false : true;
			break;
		case IM_XMLELM_PATH:
			{
				hashT id;
				id.assign(buf.c_str(), buf.size());
				CurIM->paths.push_back(id);
				while (CurIM->paths.size() > O2_BROADCAST_PATH_LIMIT)
					CurIM->paths.pop_front();
			}
			break;
	}

	buf = L"";

	CurElm = IM_XMLELM_NONE;
	if (!CurIM || !MATCHLNAME(L"message"))
		return;

	IMDB->AddMessage(*CurIM);
}
Example #2
0
void
O2KeyDB_SAX2Handler::
endElement(const XMLCh* const uri
		 , const XMLCh* const localname
		 , const XMLCh* const qname)
{
	switch (CurElm) {
		case KEY_XMLELM_HASH:
			CurKey->hash.assign(buf.c_str(), buf.size());
			break;
		case KEY_XMLELM_NODEID:
			CurKey->nodeid.assign(buf.c_str(), buf.size());
			break;
		case KEY_XMLELM_IP:
			CurKey->ip = e2ip(buf.c_str(), buf.size());
			break;
		case KEY_XMLELM_PORT:
			CurKey->port = (ushort)wcstoul(buf.c_str(), NULL, 10);
			break;
		case KEY_XMLELM_SIZE:
			CurKey->size = wcstoul(buf.c_str(), NULL, 10);
			break;
		case KEY_XMLELM_URL:
			CurKey->url = buf;
			break;
		case KEY_XMLELM_TITLE:
			if (buf.size() <= O2_MAX_KEY_TITLE_LEN)
				CurKey->title = buf;
			break;
		case KEY_XMLELM_NOTE:
			if (buf.size() <= O2_MAX_KEY_NOTE_LEN)
				CurKey->note = buf;
			break;
		case KEY_XMLELM_DATE:
			CurKey->date = datetime2time_t(buf.c_str(), buf.size());
			break;
		case KEY_XMLELM_ENABLE:
			CurKey->enable = buf[0] == L'e' ? true : false;
			break;
	}

	buf = L"";

	CurElm = KEY_XMLELM_NONE;
	if (!CurKey || !MATCHLNAME(L"key"))
		return;

	KeyDB->AddKey(*CurKey);
	ParseNum++;
}
Example #3
0
void
O2IMDB_SAX2Handler::
characters(const XMLCh* const chars, const unsigned int length)
{
	if (!CurIM)
		return;

	switch (CurElm) {
		case IM_XMLELM_IP:
			CurIM->ip = e2ip(chars, length);
			break;
		case IM_XMLELM_PORT:
			CurIM->port = (ushort)wcstoul(chars, NULL, 10);
			break;
		case IM_XMLELM_ID:
			CurIM->id.assign(chars, length);
			break;
		case IM_XMLELM_PUBKEY:
			CurIM->pubkey.assign(chars, length);
			break;
		case IM_XMLELM_NAME:
			CurIM->name.assign(chars, length);
			break;
		case IM_XMLELM_DATE:
			CurIM->date = datetime2time_t(chars, length);
			break;
		case IM_XMLELM_MSG:
			CurIM->msg.assign(chars, length);
			break;
		case IM_XMLELM_KEY:
			CurIM->key.assign(chars, length);
			break;
		case IM_XMLELM_MINE:
			CurIM->mine = chars[0] == L'0' ? false : true;
			break;
		case IM_XMLELM_PATH:
			{
				hashT id;
				id.assign(chars, length);
				CurIM->paths.push_back(id);
				while (CurIM->paths.size() > O2_BROADCAST_PATH_LIMIT)
					CurIM->paths.pop_front();
			}
			break;
	}
}