| 346 | } |
| 347 | |
| 348 | static bool getStringLogPrint(lua_State *L, char *pKey, uint16_t usLen, vector<uint8_t> &vOut) { |
| 349 | //从栈里取 table的值是一串字符串 |
| 350 | //该函数专用于写日志函数GetDataTableLogPrint, |
| 351 | if ((usLen <= 0) || (usLen > LUA_C_BUFFER_SIZE)) { |
| 352 | LogPrint(BCLog::LUAVM, "usLen error\n"); |
| 353 | return false; |
| 354 | } |
| 355 | |
| 356 | //默认栈顶是table,将key入栈 |
| 357 | lua_pushstring(L, pKey); |
| 358 | lua_gettable(L, 1); |
| 359 | |
| 360 | const char *pStr = nullptr; |
| 361 | vOut.clear(); |
| 362 | lua_getfield(L, -2, pKey); |
| 363 | // stackDump(L); |
| 364 | if (!lua_isstring(L, -1) /*LUA_TSTRING != lua_type(L, -1)*/) { |
| 365 | LogPrint(BCLog::LUAVM, "getStringLogPrint is not string\n"); |
| 366 | return false; |
| 367 | } |
| 368 | pStr = lua_tostring(L, -1 - 0); |
| 369 | if (pStr && (strlen(pStr) == usLen)) { |
| 370 | for (size_t i = 0; i < usLen; i++) { |
| 371 | vOut.insert(vOut.end(), pStr[i]); |
| 372 | } |
| 373 | // LogPrint(BCLog::LUAVM, "getfieldTableString:%s\n", pStr); |
| 374 | lua_pop(L, 1); //删掉产生的查找结果 |
| 375 | return true; |
| 376 | } else { |
| 377 | LogPrint(BCLog::LUAVM, "%s\n", "getStringLogPrint get fail\n"); |
| 378 | lua_pop(L, 1); //删掉产生的查找结果 |
| 379 | return false; |
| 380 | } |
| 381 | } |
| 382 | |
| 383 | static bool GetDataTableLogPrint(lua_State *L, vector<std::shared_ptr<std::vector<uint8_t>>> &ret) { |
| 384 | //取日志的key value |
no test coverage detected