static lua_State* luacom_DoRegistryFile(const char* luaclsid) { lua_State* L_inproc = NULL; char* fileName; char* key = new char[strlen(luaclsid)+18]; strcpy(key, "CLSID\\"); strcat(key,luaclsid); strcat(key,"\\ScriptFile"); if(tCOMUtil::GetRegKeyValue(key,&fileName)) { L_inproc = luaL_newstate(); luaL_openlibs(L_inproc); #ifdef IUP /* iuplua initialization */ iuplua_open(L_inproc); iupkey_open(L_inproc); cdlua5_open(L_inproc); #ifndef NO_CPICONTROLS controlslua_open(L_inproc); gllua_open(L_inproc); #endif #ifdef SPEECH_SDK speechlua_open(L_inproc); #endif #ifdef USE_GLLUA gl_open(L_inproc); #endif iupluaim_open(L_inproc); #endif luacom_open(L_inproc); lua_pushvalue(L_inproc, LUA_REGISTRYINDEX); lua_pushstring(L_inproc,"inproc"); lua_pushboolean(L_inproc,TRUE); lua_settable(L_inproc,-3); lua_pop(L_inproc,1); if(!lua_dofile(L_inproc,fileName)) { lua_pushstring(L_inproc,"StartAutomation"); lua_gettable(L_inproc,-2); if(luaCompat_call(L_inproc, 0, 0)) { luacom_close(L_inproc); lua_close(L_inproc); L_inproc = NULL; } } else { luacom_close(L_inproc); lua_close(L_inproc); L_inproc = NULL; } } delete[] key; SAFEDELETEARR(fileName); return L_inproc; }
int main() { if (gl_open("/tmp/tests/common/test-log.log", 1, LOG_DEBUG)) { pr_err("LOG_OPEN failed"); return 1; } gl_write(LOG_DEBUG, "This is first log, write by %s", "yanyg"); gl_write(LOG_INFO, "This is first log, write by %s", "yanyg"); gl_write(LOG_NOTICE, "This is first log, write by %s", "yanyg"); gl_write(LOG_WARNING, "This is first log, write by %s", "yanyg"); gl_write(LOG_ERR, "This is first log, write by %s", "yanyg"); gl_write(LOG_CRIT, "This is first log, write by %s", "yanyg"); gl_write(LOG_ALERT, "This is first log, write by %s", "yanyg"); gl_write(LOG_EMERG, "This is first log, write by %s", "yanyg"); gl_write(10, "This is first log, write by %s", "yanyg"); struct log_info *log; log = log_open("/tmp/tests/common/test-yyg.log", 0, LOG_NOTICE); if (!log) { DBG_PE("log_open failed"); return 1; } log_write(log, LOG_INFO, "This is yyg log %d", 1000); log_write(log, LOG_NOTICE, "This is yyg log %d", 1000); log_write(log, LOG_WARNING, "This is yyg log %d", 1000); log_close(log); log_write(log, LOG_INFO, "This is yyg log %d", 1000); log_write(log, LOG_NOTICE, "This is yyg log %d", 1000); log_write(log, LOG_WARNING, "This is yyg log %d", 1000); log = log_open("tmp/test/common/test-yyg.log", 1, LOG_WARNING); if (!log) { DBG_PE("log_open failed"); return 1; } log_write(log, LOG_INFO, "This is yyg log %d", 2000); log_write(log, LOG_NOTICE, "This is yyg log %d", 2000); log_write(log, LOG_WARNING, "This is yyg log %d", 2000); log_close(log); log_write(log, LOG_INFO, "This is yyg log %d", 2000); log_write(log, LOG_NOTICE, "This is yyg log %d", 2000); log_write(log, LOG_WARNING, "This is yyg log %d", 2000); DBG_PR("success"); return 0; }