本文整理汇总了C++中nsRefPtr::Deliver方法的典型用法代码示例。如果您正苦于以下问题:C++ nsRefPtr::Deliver方法的具体用法?C++ nsRefPtr::Deliver怎么用?C++ nsRefPtr::Deliver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsRefPtr
的用法示例。
在下文中一共展示了nsRefPtr::Deliver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Run
nsresult Run() {
struct {
HEADER hdr;
char data[1024];
} answer;
struct srv_record_t {
u_int16_t type;
u_int16_t clazz;
u_int32_t ttl;
u_int16_t size;
u_int16_t priority;
u_int16_t weight;
u_int16_t port;
char host[1];
} *srvRecord;
SRVRecord srv;
char name[256];
unsigned int answerSize = res_query(mHost.get(), C_IN, T_SRV, (u_char*)&answer,
sizeof(answer));
if (answerSize < sizeof(answer.hdr) || answerSize > sizeof(answer)) {
mRecord->Deliver(NS_ERROR_NOT_AVAILABLE);
return NS_OK;
}
u_char *end = ((u_char*)&answer)+answerSize;
answerSize -= sizeof(answer.hdr);
if (answer.hdr.rcode != NOERROR) {
mRecord->Deliver(NS_ERROR_NOT_AVAILABLE);
return NS_OK;
}
int pos = 0;
int count = ntohs(answer.hdr.qdcount);
while (--count >= 0 && answerSize >= 0) {
int size = dn_expand((u_char*)&answer, end, (u_char*)answer.data+pos,
name, sizeof(name)-1);
if (size <= 0) {
mRecord->Deliver(NS_ERROR_NOT_AVAILABLE);
return NS_OK;
}
pos += size + QFIXEDSZ;
}
count = ntohs(answer.hdr.ancount);
while (--count >= 0 && answerSize >= 0) {
int size = dn_expand((u_char*)&answer, end, (u_char*)answer.data+pos,
name, sizeof(name)-1);
pos += size;
srvRecord = (struct srv_record_t*)((char*)&answer.data+pos);
size = dn_expand((u_char*)&answer, end, (u_char*)srvRecord->host, name,
sizeof(name)-1);
if (ntohs(srvRecord->type) == T_SRV) {
srv.host = name;
srv.port = ntohs(srvRecord->port);
srv.priority = ntohs(srvRecord->priority);
srv.weight = ntohs(srvRecord->weight);
mRecord->AddSRVRecord(&srv);
}
pos += size + RRFIXEDSZ;
}
mRecord->Deliver(NS_OK);
return NS_OK;
}