MSVCMemoryDump::MSVCMemoryDump(const std::string & applicationName, const std::string & revision, const char* prefix ) //VOXOX - JRT - 2009.07.23 : MemoryDump(applicationName, revision, prefix) { std::wstring dumpPathw = str2wstr(Path::getApplicationDirPath()); std::string temp = prefix; std::wstring prefixw = str2wstr(temp); //VOXOX - JRT - 2009.07.23 _exceptionHandler = new ExceptionHandler(dumpPathw, // dump path NULL, // filter callback miniDumpCallBack, // minidump call back NULL, // call back context ExceptionHandler::HANDLER_ALL, // handler_types prefixw ); // Prefix for output file. //VOXOX - JRT - 2009.07.23 }
size_t utils::strwidth(const std::string& str) { std::wstring wstr = str2wstr(str); int width = wcswidth(wstr.c_str(), wstr.length()); if (width < 1) // a non-printable character found? return wstr.length(); // return a sane width (which might be larger than necessary) return width; // exact width }
str authdbrec2str (const sfsauth_dbrec *dbr) { strbuf sb; switch (dbr->type) { case SFSAUTH_REVINFO: return strbuf ("REVINFO:") << hexdump (dbr->revinfo->dbid.base (), dbr->revinfo->dbid.size ()) << ":" << strbuf ("%" U64F "u", dbr->revinfo->dbrev); case SFSAUTH_USER: sb << "USER:"******"GROUP:"; if (groupinfo2str (sb, dbr->groupinfo)) return sb; return NULL; case SFSAUTH_CACHEENTRY: sb << "CACHE:"; if (cacheentry2str (sb, dbr->cacheentry)) return sb; return NULL; case SFSAUTH_LOGENTRY: sb << "LOG:"; if (logentry2str (sb, dbr->logentry)) return sb; return NULL; default: return NULL; } }
static bool userinfo2str (strbuf &sb, const sfsauth_userinfo *ui) { str audit = single_char_sub (ui->audit, ':', "."); if (!namerx.match (ui->name) || (ui->owner && !namerx.match (*ui->owner)) || !nobadrx.match (ui->privs) || badcharrx.search (ui->pwauth) || badcharrx.search (audit)) return false; sb << ui->name; sb.fmt (":%u:%u:%u:", ui->id, ui->vers, ui->gid); if (ui->owner) sb << *ui->owner; sb << ":"; ptr<sfspub> pk = sfscrypt.alloc (ui->pubkey); if (!pk) return false; pk->export_pubkey (sb); sb << ":" << ui->privs << ":" << ui->pwauth << ":"; str priv = str2wstr (armor64 (ui->privkey.base (), ui->privkey.size())); sb << priv << ":"; sfs_2schnorr_priv::export_keyhalf (ui->srvprivkey, sb); // sb << ":" << ui->refresh << ":" << ui->timeout; sb << ":" << audit; return true; }
VARIANT* GpuCapabilitiesWindows::WMIquery(std::string wmiClass, std::string attribute) { // Code based upon: "Example: Getting WMI Data from the Local Computer" // http://msdn2.microsoft.com/en-us/library/aa390423.aspx if (!isWMIinited()) { LWARNING("WMI not initiated"); return 0; } HRESULT hres; VARIANT* result = 0; // Step 6: -------------------------------------------------- // Use the IWbemServices pointer to make requests of WMI ---- IEnumWbemClassObject* pEnumerator = NULL; std::string query = "SELECT " + attribute + " FROM " + wmiClass; hres = pWbemServices_->ExecQuery( bstr_t("WQL"), bstr_t(query.c_str()), WBEM_FLAG_FORWARD_ONLY | WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &pEnumerator); if (FAILED(hres)) { LWARNING("ERROR: WMI query failed: " << query); return 0; } // Step 7: ------------------------------------------------- // Get the data from the query in step 6 ------------------- IWbemClassObject* pclsObj = 0; ULONG uReturn = 0; if (pEnumerator) { HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn); if (uReturn) { // Get the value of the attribute and store it in result result = new VARIANT; hr = pclsObj->Get(LPCWSTR(str2wstr(attribute).c_str()), 0, result, 0, 0); } } if (!result) { LWARNING("No WMI query result"); } // Clean enumerator and pclsObject if (pEnumerator) pEnumerator->Release(); if (pclsObj) pclsObj->Release(); return result; }
tstring str2tstr(const std::string& st ) { #ifdef _UNICODE return str2wstr(st); #else return st; #endif }
//------------------------------------------------------------------------ // 스트링포맷 wstring 용 //------------------------------------------------------------------------ std::wstring common::formatw(const char* fmt, ...) { char textString[ 256] = {'\0'}; va_list args; va_start ( args, fmt ); vsnprintf_s( textString, sizeof(textString), _TRUNCATE, fmt, args ); va_end ( args ); return str2wstr(textString); }
void bs_table::add_column(const std::string &_name) { column last_column; columns.push_back (last_column); columns.back ().name = str2wstr(_name); columns.back ().data.resize (n_rows); }
std::wstring CTest::GetXMLAttributeValue( rapidxml::xml_node<>* pNode, const std::wstring& strwKey ) { std::string straKey = wstr2str(strwKey, CP_UTF8); std::wstring strwValue; rapidxml::xml_attribute<>* xmlattribute = pNode->first_attribute(straKey.c_str()); if (xmlattribute != NULL) { std::string straValue = xmlattribute->value(); strwValue = str2wstr(straValue, CP_UTF8); } return strwValue; }
std::wstring CTestjsoncpp::ReleaseJsonStr() { Json::Value jvData = ReleaseJsonValue(); //压缩输出 //Json::FastWriter fastwriter; //std::string strJson = fastwriter.write(jvData); //return str2wstr(strJson, CP_ACP); //格式化输出 Json::StyledWriter stylewriter; std::string strJson = stylewriter.write(jvData); return str2wstr(strJson, CP_UTF8); }
// 지형 텍스쳐 리스트 출력. void CHeightMapPanel::UpdateTextureList() { // 리스트 박스 초기화. while (0 < m_TextureList.GetCount()) m_TextureList.DeleteString(0); // 파일 찾기. list<string> extList; extList.push_back("jpg"); extList.push_back("png"); extList.push_back("bmp"); list<string> textureFiles; common::CollectFiles(extList, "../../media/terrain/", textureFiles); BOOST_FOREACH(auto &fileName, textureFiles) { const wstring wstr = str2wstr(fileName); m_TextureList.InsertString(m_TextureList.GetCount(), wstr.c_str()); } }
// ../media 폴더에서 *.ani 파일을 찾아서 리스팅한다. void CFilePanel::UpdateAnimationFiles() { // 리스트 박스 초기화. while (0 < m_AnimationFileList.GetCount()) m_AnimationFileList.DeleteString(0); // 파일 찾기. list<string> extList; extList.push_back("ani"); list<string> aniFiles; common::CollectFiles(extList, "../media/", aniFiles); BOOST_FOREACH(auto &fileName, aniFiles) { const wstring wstr = str2wstr(fileName); m_AnimationFileList.InsertString(m_AnimationFileList.GetCount(), wstr.c_str()); } m_textAnimationFiles.Format( L"Animation Files : %d", aniFiles.size()); UpdateData(FALSE); }
bool str2authdbrec (sfsauth_dbrec *dbr, str s) { static rxx _userrx ("^USER:(.*)$"); rxx userrx (_userrx); static rxx grouprx ("^GROUP:(.*)$"); static rxx cacherx ("^CACHE:(.*)$"); static rxx logrx ("^LOG:(.*)$"); static rxx revinfo ("^REVINFO:([0-9a-fA-F]+):(\\d+)$"); if (revinfo.match (s)) { str id = hex2bytes (revinfo[1]); u_int64_t rev; if (!id || id.len () != sizeof (dbr->revinfo->dbid) || !convertint (revinfo[2], &rev)) return false; dbr->set_type (SFSAUTH_REVINFO); dbr->revinfo->dbrev = rev; memcpy (dbr->revinfo->dbid.base (), id, id.len ()); return true; } else if (userrx.match (s)) { dbr->set_type (SFSAUTH_USER); return str2userinfo (dbr->userinfo, str2wstr (userrx[1])); } else if (grouprx.match (s)) { dbr->set_type (SFSAUTH_GROUP); return str2groupinfo (dbr->groupinfo, grouprx[1]); } else if (cacherx.match (s)) { dbr->set_type (SFSAUTH_CACHEENTRY); return str2cacheentry (dbr->cacheentry, cacherx[1]); } else if (logrx.match (s)) { dbr->set_type (SFSAUTH_LOGENTRY); return str2logentry (dbr->logentry, logrx[1]); } else return false; }
int CMessageWidget::CustDraw(CFrameSurface* pSurface) { CImageWidget::CustDraw(pSurface); WRect rc; GetRectAsScreen(&rc); uint8* str=(uint8*)(m_str.GetBuffer(0)); int len=m_str.GetLength(); int wlen=len+1; uint16* wstr=(uint16*)EG_MALLOC(wlen*sizeof(uint16)); str2wstr(str,len,wstr,wlen); pSurface->DrawText(wstr,len, &rc,DT_CENTER|DT_WORDBREAK); return 0; }
wstring DblToStr(float fltVal) { char buff[50]; _gcvt_s(buff,sizeof(buff),fltVal, 10); return str2wstr(string(buff)); }
wstring DblToStr(double dblVal, int ndigits) { char buff[50]; _gcvt_s(buff,sizeof(buff),dblVal, ndigits); return str2wstr(string(buff)); }
bool str2userinfo (sfsauth_userinfo *ui, str s) { str name; vec<str> uv; if (split (&uv, colon, s, 12, true) != 11) return false; str2wstr (uv[7]); str2wstr (uv[8]); str fields[13] = { "name", "uid", "version", "gid", "owner", "pubkey", "privs", "srp", "privkey", "srvprivkey", // "refresh", "timeout", "audit" }; if (!namerx.match (uv[0])) { err_report ("<null>", 1, fields[0], uv[0]); return false; } name = uv[0]; for (int i = 1; i < 4; i++) { if (!decrx.match (uv[i])) { err_report (name, i+1, fields[i], uv[i]); return false; } } if (uv[4].len () && !namerx.match (uv[4])) { err_report (name, 5, fields[4], uv[4]); return false; } for (int i = 6; i < 10; i++) { if (badcharrx.search (uv[i])) { err_report (name, i+1, fields[i], uv[i]); return false; } } #if 0 for (int i = 10; i < 12; i++) { if (!decrx.match (uv[i])) { err_report (name, i+1, fields[i], uv[i]); return false; } } #endif str privkey = dearmor64 (uv[8]); if (!privkey) { err_report (name, 9, fields[8], "could not dearmor64"); return false; } str2wstr (privkey); ui->privkey.setsize (privkey.len ()); memcpy (ui->privkey.base (), privkey, ui->privkey.size ()); ui->name = uv[0]; if (!convertint (uv[1], &ui->id) || !convertint (uv[2], &ui->vers) || !convertint (uv[3], &ui->gid) // || !convertint (uv[10], &ui->refresh) // || !convertint (uv[11], &ui->timeout) ) return false; if (uv[4].len ()) *ui->owner.alloc () = uv[4]; else ui->owner.clear (); ptr<sfspub> pk = sfscrypt.alloc (uv[5]); if (!pk) return false; if (!pk->export_pubkey (&ui->pubkey)) { warn << "Cannot load keypair for " << uv[0] << "\n"; return false; } ui->privs = uv[6]; ui->pwauth = uv[7]; if (uv[9] && uv[9].len ()) { if (!sfs_2schnorr_priv::parse_keyhalf (&ui->srvprivkey, uv[9])) { warn << "Cannot load server keyhalf for " << uv[0] << "\n"; return false; } } else { ui->srvprivkey.set_type (SFSAUTH_KEYHALF_NONE); } // ui->audit = uv[12]; ui->audit = uv[10]; return true; }
void GUIUpdate() { GUISystem.clear(); char text[50]; sprintf(text, "fps:%d", scene.fps); GUISystem.GUILabel(text, Rect(10, 10, 100, 25), leftAlignStyle); sprintf(text, "culledChunks:%d", (*(scene.terrains.begin()))->culledChunks); GUISystem.GUILabel(text, Rect(110, 10, 200, 25), leftAlignStyle); static bool showSettings = false; if(GUISystem.GUIButton("Settings", Rect(10, 40, 100, 25))) showSettings = !showSettings; GUISystem.GUILabel("操作:按住鼠标右键旋转摄像机,WASDQE移动", Rect(10, 70, 400, 25), leftAlignStyle); if(showSettings){ GUISystem.GUILabel("Time:", Rect(10, 100, 100, 25), leftAlignStyle); static int cubieMaterialIx = 0; vector<LPWSTR> listItems; listItems.push_back(str2wstr("BasicSpecular")); listItems.push_back(str2wstr("BumpMapping")); listItems.push_back(str2wstr("NormalMapping")); listItems.push_back(str2wstr("POM")); cubieMaterialIx = GUISystem.GUIListBox(listItems, Rect(400, 70, 200, 25), cubieMaterialIx, "cubieMaterialIx"); switch(cubieMaterialIx){ case 0: cubie.shader = Specular; cubie.material = mtlBrickS; break; case 1: cubie.shader = BumpHSpecular; cubie.material = mtlBrickB; break; case 2: cubie.shader = BumpSpecular; cubie.material = mtlBrickN; break; case 3: cubie.shader = BumpPOMSpecular; cubie.material = mtlBrickPOM; break; } static int timeCount = 0; timeCount = GUISystem.GUISlider(Rect(110, 100, 200, 25), 0, 3600*24 - 1, timeCount, "sliderHour"); int h = timeCount/3600; int m = (timeCount - 3600*h)/60; int s = timeCount%60; sprintf(text, "%d:%d:%d", h, m, s); GUISystem.GUILabel(text, Rect(310, 100, 100, 25)); DayTime::SetDayTime(h, m, s); /*static bool flag = false; flag = GUISystem.GUIToggle(Rect(10, 100, 25, 25), flag);*/ static D3DXCOLOR color0h_z = scene.skyColor[0].zenithColor; static D3DXCOLOR color0h_w = scene.skyColor[0].westColor; static D3DXCOLOR color0h_e = scene.skyColor[0].eastColor; static D3DXCOLOR color6h_z = scene.skyColor[1].zenithColor; static D3DXCOLOR color6h_w = scene.skyColor[1].westColor; static D3DXCOLOR color6h_e = scene.skyColor[1].eastColor; static D3DXCOLOR color12h_z = scene.skyColor[2].zenithColor; static D3DXCOLOR color12h_w = scene.skyColor[2].westColor; static D3DXCOLOR color12h_e = scene.skyColor[2].eastColor; static D3DXCOLOR color18h_z = scene.skyColor[3].zenithColor; static D3DXCOLOR color18h_w = scene.skyColor[3].westColor; static D3DXCOLOR color18h_e = scene.skyColor[3].eastColor; color0h_z = GUISystem.GUIColor(Rect(10, 130, 25, 25), color0h_z, "color0h_z"); color0h_w = GUISystem.GUIColor(Rect(170, 130, 25, 25), color0h_w, "color0h_w"); color0h_e = GUISystem.GUIColor(Rect(330, 130, 25, 25), color0h_e, "color0h_e"); color6h_z = GUISystem.GUIColor(Rect(10, 240, 25, 25), color6h_z, "color6h_z"); color6h_w = GUISystem.GUIColor(Rect(170, 240, 25, 25), color6h_w, "color6h_w"); color6h_e = GUISystem.GUIColor(Rect(330, 240, 25, 25), color6h_e, "color6h_e"); color12h_z = GUISystem.GUIColor(Rect(10, 350, 25, 25), color12h_z, "color12h_z"); color12h_w = GUISystem.GUIColor(Rect(170, 350, 25, 25), color12h_w, "color12h_w"); color12h_e = GUISystem.GUIColor(Rect(330, 350, 25, 25), color12h_e, "color12h_e"); color18h_z = GUISystem.GUIColor(Rect(10, 460, 25, 25), color18h_z, "color18h_z"); color18h_w = GUISystem.GUIColor(Rect(170, 460, 25, 25), color18h_w, "color18h_w"); color18h_e = GUISystem.GUIColor(Rect(330, 460, 25, 25), color18h_e, "color18h_e"); scene.skyColor[0].zenithColor = D3DCOLOR_XRGB((int)(color0h_z.r*255), (int)(color0h_z.g*255), (int)(color0h_z.b*255)); scene.skyColor[0].westColor = D3DCOLOR_XRGB((int)(color0h_w.r*255), (int)(color0h_w.g*255), (int)(color0h_w.b*255)); scene.skyColor[0].eastColor = D3DCOLOR_XRGB((int)(color0h_e.r*255), (int)(color0h_e.g*255), (int)(color0h_e.b*255)); scene.skyColor[1].zenithColor = D3DCOLOR_XRGB((int)(color6h_z.r*255), (int)(color6h_z.g*255), (int)(color6h_z.b*255)); scene.skyColor[1].westColor = D3DCOLOR_XRGB((int)(color6h_w.r*255), (int)(color6h_w.g*255), (int)(color6h_w.b*255)); scene.skyColor[1].eastColor = D3DCOLOR_XRGB((int)(color6h_e.r*255), (int)(color6h_e.g*255), (int)(color6h_e.b*255)); scene.skyColor[2].zenithColor = D3DCOLOR_XRGB((int)(color12h_z.r*255), (int)(color12h_z.g*255), (int)(color12h_z.b*255)); scene.skyColor[2].westColor = D3DCOLOR_XRGB((int)(color12h_w.r*255), (int)(color12h_w.g*255), (int)(color12h_w.b*255)); scene.skyColor[2].eastColor = D3DCOLOR_XRGB((int)(color12h_e.r*255), (int)(color12h_e.g*255), (int)(color12h_e.b*255)); scene.skyColor[3].zenithColor = D3DCOLOR_XRGB((int)(color18h_z.r*255), (int)(color18h_z.g*255), (int)(color18h_z.b*255)); scene.skyColor[3].westColor = D3DCOLOR_XRGB((int)(color18h_w.r*255), (int)(color18h_w.g*255), (int)(color18h_w.b*255)); scene.skyColor[3].eastColor = D3DCOLOR_XRGB((int)(color18h_e.r*255), (int)(color18h_e.g*255), (int)(color18h_e.b*255)); } }
string_t CurlWriter::getErrorData () const { return str2wstr(_stream.str()); }
static void getflags(int *xargc, char ***xargv, int *option_end) { char *arg; char *t; wchar_t *s[3]; while (*xargc > 1) { arg = (*xargv)[1]; /* point arg to current argument */ /* * This argument is not an option if it equals "-" or if * "--" has already been parsed. */ if (arg[0] != '-' || arg[1] == EOS || *option_end) break; if (arg[0] == '-' && arg[1] == '-' && arg[2] == '\0') { *option_end = 1; } else { switch (arg[1]) { case 'B': chkspace(&arg, xargc, xargv); bufsize = atoi(&arg[2]); if (bufsize <= 0) { bufsize = DEF_BUFSIZE; } break; case 'D': initalloc(); chkspace(&arg, xargc, xargv); for (t = &arg[2]; *t; t++) { if (*t == '=') { *t++ = EOS; break; } } s[1] = str2wstr(&arg[2], 1); s[2] = str2wstr(t, 1); dodef(&s[0], 2); free(s[1]); free(s[2]); break; case 'H': chkspace(&arg, xargc, xargv); hshsize = atoi(&arg[2]); if (hshsize <= 0) { hshsize = DEF_HSHSIZE; } break; case 'S': chkspace(&arg, xargc, xargv); stksize = atoi(&arg[2]); if (stksize <= 0) { stksize = DEF_STKSIZE; } break; case 'T': chkspace(&arg, xargc, xargv); toksize = atoi(&arg[2]); if (toksize <= 0) { toksize = DEF_TOKSIZE; } break; case 'U': initalloc(); chkspace(&arg, xargc, xargv); s[1] = str2wstr(&arg[2], 1); doundef(&s[0], 1); free(s[1]); break; case 'e': setbuf(stdout, NULL); (void) signal(SIGINT, SIG_IGN); break; case 's': /* turn on line sync */ sflag = 1; break; default: (void) fprintf(stderr, gettext("%s: bad option: %s\n"), procnam, arg); delexit(NOT_OK, 0); } } /* end else not "--" */ (*xargv)++; --(*xargc); } /* end while options to process */ }