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); }
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++; }
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; } }
void O2Profile_SAX2Handler:: endElement(const XMLCh* const uri , const XMLCh* const localname , const XMLCh* const qname) { switch (CurElm) { case PROF_XMLELM_ID: Profile->ID.assign(buf.c_str(), buf.size()); break; case PROF_XMLELM_PRIVKEY: Profile->PrivKey.assign(buf.c_str(), buf.size()); break; case PROF_XMLELM_PUBKEY: Profile->PubKey.assign(buf.c_str(), buf.size()); break; case PROF_XMLELM_IP: Profile->IP = e2ip(buf.c_str(), buf.size()); break; case PROF_XMLELM_P2PPORT: Profile->P2PPort = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case PROF_XMLELM_PROXYPORT: Profile->ProxyPort = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case PROF_XMLELM_ADMINPORT: Profile->AdminPort = (ushort)wcstoul(buf.c_str(), NULL, 10); break; case PROF_XMLELM_NAME: if (buf.size() <= O2_MAX_NAME_LEN) { Profile->SetNodeName(buf.c_str()); } break; case PROF_XMLELM_COMMENT: if (buf.size() <= O2_MAX_COMMENT_LEN) { for (size_t i = 0; i < buf.size(); i++) { if (buf[i] == L'\n') Profile->Comment += L"\r\n"; else Profile->Comment += buf[i]; } } break; case PROF_XMLELM_DBDIR: Profile->SetDBDir(buf.c_str()); break; case PROF_XMLELM_CACHEROOT: Profile->SetCacheRoot(buf.c_str()); break; case PROF_XMLELM_ADMINROOT: Profile->SetAdminRoot(buf.c_str()); break; case PROF_XMLELM_ADMIN_BROWSER_TYPE: Profile->AdminBrowserType = buf; break; case PROF_XMLELM_ADMIN_BROWSER_PATH: Profile->AdminBrowserPath = buf; break; case PROF_XMLELM_UPNP_ADAPTERNAME: unicode2ascii(buf, Profile->UPnPAdapterName); break; case PROF_XMLELM_UPNP_LOCATION: unicode2ascii(buf, Profile->UPnPLocation); break; case PROF_XMLELM_UPNP_SERVICEID: unicode2ascii(buf, Profile->UPnPServiceId); break; case PROF_XMLELM_LIMIT: if (plimit) *plimit = wcstoul(buf.c_str(), NULL, 10); break; case PROF_XMLELM_SIZE_T: if (puint64) *puint64 = _wcstoui64(buf.c_str(), NULL, 10); break; case PROF_XMLELM_BOOL: *pbool = buf[0] == '1' ? true : false; break; } buf = L""; CurElm = PROF_XMLELM_NONE; if (!MATCHLNAME(L"profile")) return; if (Profile->PrivKey.size() != RSA_PRIVKEY_SIZE || Profile->PubKey.size() != RSA_PUBKEY_SIZE) { Profile->SetRSAKey(NULL, 0, NULL, 0); } }