本文整理汇总了C++中plString::len方法的典型用法代码示例。如果您正苦于以下问题:C++ plString::len方法的具体用法?C++ plString::len怎么用?C++ plString::len使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plString
的用法示例。
在下文中一共展示了plString::len方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cdUp
plString cdUp(plString path) {
// Check for root paths, we can't go up from there!
#ifdef WIN32
if (path.mid(1) == ":\\")
return path;
#else
if (path == "/")
return path;
#endif
// Not very robust, but it works for one level of parent scanning
if (path.empty())
return ".." PATHSEPSTR;
// Strip the ending slash, if necessary, and then go up one dir
if (path[path.len()-1] == PATHSEP)
path = path.left(path.len() - 1);
plString up = path.beforeLast(PATHSEP);
if (path[0] == PATHSEP) {
// Absolute path specified -- make sure we keep it that way
return up + PATHSEP;
} else {
// Relative path specified
return up.empty() ? "" : up + PATHSEP;
}
}
示例2: sendAcctLoginRequest
uint32_t pnAuthClient::sendAcctLoginRequest(uint32_t serverChallenge,
uint32_t clientChallenge, const plString& acctName,
const plString& password, const plString& authToken,
const plString& os)
{
const pnNetMsg* desc = GET_Cli2Auth(kCli2Auth_AcctLoginRequest);
msgparm_t* msg = NCAllocMessage(desc);
uint32_t transId = nextTransId();
msg[0].fUint = transId;
msg[1].fUint = clientChallenge;
msg[2].fString = plwcsdup(acctName.wstr());
pnSha1Hash hash;
if (acctName.find('@') != -1 && acctName.find("@gametap") == -1
&& acctName.find("@magiquest") == -1) {
hash = NCHashLoginInfo(acctName, password, serverChallenge, clientChallenge);
} else {
hash = pnSha1Hash::Sha1(password.cstr(), password.len());
hash.swapBytes(); // Cyan uses a different byte order for this case
}
memcpy(msg[3].fData, &hash, sizeof(hash));
msg[4].fString = plwcsdup(authToken.wstr());
msg[5].fString = plwcsdup(os.wstr());
fSock->sendMsg(msg, desc);
NCFreeMessage(msg, desc);
return transId;
}
示例3: while
plMD5Hash plMD5::hashString(const plString& str) {
plMD5 ctx;
size_t size = str.len();
unsigned char buf[64];
size_t pos = 0;
while (pos + 64 <= size) {
memcpy(buf, str.cstr() + pos, 64);
ctx.processBlock(buf);
pos += 64;
}
// Final block
size_t lastSize = size - pos;
memcpy(buf, str.cstr() + pos, lastSize);
if (lastSize >= 56) {
memcpy(buf + lastSize, kPadArray, 64 - lastSize);
ctx.processBlock(buf);
memset(buf, 0, sizeof(buf));
} else {
unsigned int padBytes = 56 - lastSize;
memcpy(buf + lastSize, kPadArray, padBytes);
}
unsigned int bitSize[2];
bitSize[0] = LESWAP32((size << 3));
bitSize[1] = LESWAP32((size >> 29));
memcpy(buf + 56, bitSize, sizeof(bitSize));
ctx.processBlock(buf);
plMD5Hash hash;
hash.fHash[0] = ctx.fA;
hash.fHash[1] = ctx.fB;
hash.fHash[2] = ctx.fC;
hash.fHash[3] = ctx.fD;
return hash;
};