//将字符串翻译为加速键 DWORD CAccelerator::TranslateAccelKey( LPCTSTR pszAccelKey ) { TCHAR szBuf[101]={0};//保证字符串结束有两个结束符 WORD wModifier=0; WORD wKey=0; int nKeyLen=(int)_tcslen(pszAccelKey); if(_tcslen(pszAccelKey)>=100) return 0; _tcscpy(szBuf,pszAccelKey); CharLowerBuff(szBuf,nKeyLen); LPTSTR pszBuf=szBuf; LPTSTR pszKey=_tcstok(pszBuf,_T("+")); while(pszKey) { if(_tcsicmp(pszKey,_T("ctrl"))==0) { wModifier|=MOD_CONTROL; }else if(_tcsicmp(pszKey,_T("alt"))==0) { wModifier |=MOD_ALT; }else if(_tcsicmp(pszKey,_T("shift"))==0) { wModifier |= MOD_SHIFT; }else { wKey = VkFromString(pszKey); break; } pszBuf+=_tcslen(pszKey)+1; pszKey=_tcstok(pszBuf,_T("+")); } return MAKELONG(wKey,wModifier); }
void appendPseudoTargetList( STRINGLIST **pseudo, STRINGLIST *list ) { STRINGLIST *p, *q, *r; char *t, *u; while ((p = list)) { if (!_tcschr(p->text, '$')) { list = list->next; p->next = NULL; appendItem(pseudo, p); } else { r = macros; t = expandMacros(p->text, ¯os); while (r != macros) { q = r->next; FREE_STRINGLIST(r); r = q; } for (u = _tcstok(t, " \t"); u; u = _tcstok(NULL, " \t")) { q = makeNewStrListElement(); q->text = makeString(u); appendItem(pseudo, q); } FREE(t); FREE(p->text); list = list->next; FREE_STRINGLIST(p); } } }
/************************************************************************** * Global Hex-Edit-Functions */ BOOL IsExtensionRegistered(LPCTSTR file) { BOOL bRet = FALSE; LPTSTR TEMP = (LPTSTR) new TCHAR[MAX_PATH]; LPTSTR ptr = NULL; if (TEMP != NULL) { _tcscpy(TEMP, prop.autoProp.szExtensions); ptr = _tcstok(TEMP, _T(" ")); while (ptr != NULL) { if (_tcsicmp(&file[_tcslen(file) - _tcslen(ptr)], ptr) == 0) { bRet = TRUE; break; } ptr = _tcstok(NULL, _T(" ")); } delete [] TEMP; } return bRet; }
int WINAPI WinMain( HINSTANCE, HINSTANCE, LPSTR, int ) { //! \todo Verify that this properly creates argc/argv. TCHAR cmdline[4096]; TCHAR * argv [4096]; int argc = 0; _tcscpy(cmdline, GetCommandLine()); argv[argc] = _tcstok(cmdline, TEXT(" \t")); while (argv[argc] != 0) { argc++; argv[argc] = _tcstok(0, TEXT(" \t")); } return main(argc, argv); }
void CNetwork::SetConnectData(const CString& text, CNetwork::Server& server) const { TCHAR buffer[MAX_PATH] = {0}; _tcsncpy( buffer, text, sizeof( buffer ) / sizeof( *buffer ) ); LPCTSTR seperator = _T( "\t: " ); // 091012 LUJ, IP 정보를 얻는다 server.mIP = _tcstok( buffer, seperator); // 포트 정보가 있다면 얻어온다 LPCTSTR tokenPort = _tcstok( 0, seperator); if( tokenPort ) { server.mPort = WORD( _ttoi( tokenPort ) ); } else { const WORD defaultPort( 23900 ); server.mPort = defaultPort; } }
static int audioOutputInit() { if (!hAudioDlg) { return 1; } const TCHAR* list = audio.driver_list(); // audio output string list TCHAR szToken[MAX_PATH]; _tcscpy(szToken, list); TCHAR* token = _tcstok(szToken, _T(";")); int index = 0; while (token) { SendDlgItemMessage(hAudioDlg, IDC_PREF_AUDIOOUTPUT, CB_ADDSTRING, 0, (LPARAM)token); // set selected audio output if (!_tcscmp(audSelect, token)) { SendDlgItemMessage(hAudioDlg, IDC_PREF_AUDIOOUTPUT, CB_SETCURSEL, (WPARAM)index, 0); } token = _tcstok(NULL, _T(";")); index++; } free(token); return 0; }
void SQLServerUtils::FindInstanceName(const TCHAR* instance, TCHAR* namedInstance) { if(!instance) return; TCHAR str[MAX_PATH] = {NULL}; TCHAR* delims[] = {_T("\\"), _T("$"), _T(".")}; TCHAR *result = NULL; _tcscpy(str, instance); size_t len = _tcslen(str); for(int i=0; i<3; i++) { result = _tcstok(str, delims[i]); if(result != NULL && _tcslen(result) != len) { // Get Named Instance result = _tcstok(NULL, delims[i]); if(result != NULL) { _tcscpy(namedInstance, result); return; } } } _tcscpy(namedInstance, instance); }
static void LoadInternalExceptionList() { g_aException.SetCount( 0, 32 ); LPCTSTR rs = NULL; size_t len = AtlLoadString( IDS_INTERNAL_EXCEPTIONS, reinterpret_cast<LPTSTR>(&rs), 0 ); LPTSTR buf = reinterpret_cast<LPTSTR>( malloc((len + 1) * sizeof(TCHAR)) ); _tcsncpy( buf, rs, len ); buf[len] = 0; LPCTSTR p = _tcstok( buf, _T("|") ); while( p != NULL ) { CExceptionInfo ei; ei.bUser = false; ei.bFiltered = false; ei.dwCode = _tcstoul( p, NULL, 0 ); p = _tcstok( NULL, _T("|") ); _tcsncpy( ei.szName, p, _countof(ei.szName) ); ei.szName[_countof(ei.szName) - 1] = 0; g_aException.Add( ei ); p = _tcstok( NULL, _T("|") ); } free( buf ); }
//----------------------------------------------------------------- // Load the static blacklists into Trie (Prefix Tree) //----------------------------------------------------------------- BOOL populateStaticBlacklist(LPTSTR lpszFileName) { wchar_t line[MAX_PATH]; FILE *hFile; wchar_t * key; wchar_t * path; hFile = _wfopen(lpszFileName, L"rb, ccs=UTF-16LE"); while (fgetws(line, MAX_PATH, hFile)) { // Remove newline character if (line[_tcslen(line) - 1] == (TCHAR)'\n') { line[_tcslen(line) - 1] = (TCHAR)'\0'; } // Remove carrige return character if (line[_tcslen(line) - 1] == (TCHAR)'\r') { line[_tcslen(line) - 1] = (TCHAR)'\0'; } // If line does not start with a hash ('#'), add to blacklist if (line[0] != (TCHAR)'#') { if (line == NULL) { continue; } //wchar_t * key = _tcstok(line, L"="); //wchar_t * path = _tcstok(NULL, L"="); key = _tcstok(line, L"="); path = _tcstok(NULL, L"="); if (key == NULL || path == NULL) { continue; } if (_tcscmp(key, _T("DIR")) == 0) { TrieAdd(&blacklistDIRS, path); } if (_tcscmp(key, _T("FILE")) == 0) { TrieAdd(&blacklistFILES, path); } if (_tcscmp(key, _T("KEY")) == 0) { TrieAdd(&blacklistKEYS, path); } if (_tcscmp(key, _T("VALUE")) == 0) { TrieAdd(&blacklistVALUES, path); } } } //LPTSTR string = TEXT("HKLM\\SYSTEM\\ControlSet002"); //BOOL found = TrieSearchPath(blacklistKEYS->children, string); //printf("FOUND: %d", found); // All done with loading blacklist, so close file handle and return fclose(hFile); return TRUE; }
// ----------------------------------------------------------------------------- // Insert a Full path of Items and creates all new nodes TreeNode *TreeInsertItems(Tree *tree, TreeNode *parent, HTTPCHAR *strpath) { TreeNode *node; HTTPCHAR *str = _tcsdup(strpath); int IsFolder = (str[strlen(str) - 1] == '/'); HTTPCHAR *path = _tcstok(str, "/"); if (!path) { node = TreeInsert(tree, parent, ""); } else { TreeNode *currentparent = parent; Tree *base = tree; do { node = TreeInsert(base, currentparent, path); path = _tcstok(NULL, "/"); if ((path) || (IsFolder)) { if (!node->SubItems) { node->SubItems = TreeInitialize("/"); } currentparent = node; base = node->SubItems; } else { break; } } while (path != NULL); } free(str); return (node); }
int LoadRouterAuth(HTTPCSTR path) { FILE *RouterAuth; HTTPCHAR line[200]; HTTPCHAR *p; //int nRouterAuth=0; nRouterAuth=0; RouterAuth=_tfopen(path,_T("r")); if (RouterAuth) { while (!feof(RouterAuth)) { _fgetts(line,sizeof(line)/sizeof(HTTPCHAR)-1,RouterAuth); if ( (_tcslen(line)>5) && line[0]!=_T('#') ) { p=line+_tcslen(line)-1; while ( (*p==_T('\r') ) || (*p==_T('\n')) || (*p==_T(' ')) ) { p[0]=_T('\0'); --p; } p=_tcstok(line,_T("|")); FakeAuth[nRouterAuth].status=_tstoi(p); p=_tcstok(NULL,_T("|")); _tcsncpy(FakeAuth[nRouterAuth].server,p,sizeof(FakeAuth[nRouterAuth].server)/sizeof(HTTPCHAR)-1); if ( (_tcslen(p)==1) && (p[0]==_T('*')) ) FakeAuth[nRouterAuth].server[0]=_T('\0'); p=_tcstok(NULL,_T("|")); _tcsncpy(FakeAuth[nRouterAuth].authurl,p,sizeof(FakeAuth[nRouterAuth].authurl)/sizeof(HTTPCHAR)-1); p=_tcstok(NULL,_T("|")); _tcsncpy(FakeAuth[nRouterAuth].method,p,sizeof(FakeAuth[nRouterAuth].method)/sizeof(HTTPCHAR)-1); p=_tcstok(NULL,_T("|")); if (p) _tcsncpy(FakeAuth[nRouterAuth].postdata,p,sizeof(FakeAuth[nRouterAuth].postdata)/sizeof(HTTPCHAR)-1); nRouterAuth++; } } fclose(RouterAuth); } return(nRouterAuth); }
int CmdProcessing(void) { _fputts(_T("Best command prompt>> "), stdout); _getts(cmdString); TCHAR * token = _tcstok(cmdString, seps); int tokenNum = 0; while (token != NULL) { _tcscpy( cmdTokenList[tokenNum++], StrLower(token) ); token = _tcstok(NULL, seps); } if (!_tcscmp(cmdTokenList[0], _T("exit"))) { return TRUE; } else if (!_tcscmp(cmdTokenList[0], _T("추가 되는 명령어 1"))) { } else if (!_tcscmp(cmdTokenList[0], _T("추가 되는 명령어 2"))) { } else { _tprintf(ERROR_CMD, cmdTokenList[0]); } return 0; }
void SQLServerUtils::SplitInstanceName(const TCHAR* instance, TCHAR* hostname, TCHAR* namedInstance) { if(!instance) return; TCHAR str[MAX_PATH] = {NULL}; TCHAR delims[] = _T("\\"); TCHAR *result = NULL; _tcscpy(str, instance); size_t len = _tcslen(str); result = _tcstok(str, delims); if(result != NULL && _tcslen(result) != len) { // Get Host Name _tcscpy(hostname, result); // Get Named Instance result = _tcstok(NULL, delims); if(result != NULL) { _tcscpy(namedInstance, result); return; } } _tcscpy(namedInstance, instance); };
LRESULT CSelProcDlg::OnInitDialog( UINT, WPARAM, LPARAM, BOOL& ) { m_hProc = NULL; DlgResize_Init( false ); m_lst.SubclassWindow( GetDlgItem( IDC_PROCESS_LIST ) ); DWORD dwStyle = LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES; dwStyle |= LVS_EX_HEADERDRAGDROP; m_lst.SetExtendedListViewStyle( dwStyle ); TCHAR szHeaders[128]; AtlLoadString( IDS_PROCESS_LIST_HEADER, szHeaders, _countof(szHeaders) ); RECT rect; m_lst.GetWindowRect( &rect ); int nWidth = rect.right - rect.left; int nIndex = 0; LPCTSTR sz = _tcstok( szHeaders, _T("\n") ); while( sz != NULL ) { int w = _ttoi(_tcstok( NULL, _T("\n") )) * nWidth / 100; m_lst.InsertColumn( nIndex++, sz, LVCFMT_LEFT, w, 0 ); sz = _tcstok( NULL, _T("\n") ); } m_lst.SetColumnSortType( 0, LVCOLSORT_TEXTNOCASE ); m_lst.SetColumnSortType( 1, LVCOLSORT_LONG ); m_lst.SetColumnSortType( 2, LVCOLSORT_TEXTNOCASE ); m_lst.SetSortColumn( 0 ); RefreshProcessList(); return TRUE; }
static void JabberAcceptGroupchatInvite( TCHAR* roomJid, TCHAR* reason, TCHAR* password ) { TCHAR room[256], *server, *p; _tcsncpy( room, roomJid, SIZEOF( room )); p = _tcstok( room, _T( "@" )); server = _tcstok( NULL, _T( "@" )); JabberGroupchatJoinRoom( server, p, reason, password ); }
void cDialogueList::LoadScript() { CMHFile file; file.Init( "Data/Script/Npc/Npc_Msg.bin", "rb"); DWORD messageIndex = 0; WORD wLineIdx = 0; while(FALSE == file.IsEOF()) { // 091207 LUJ, 1K 이하로 선언하면 메모리 오류가 발생한다... 그런데 파싱 코드가 겁나게 복잡하다. TCHAR buffer[1024] = {0}; file.GetLine( buffer, sizeof(buffer) / sizeof(*buffer)); TCHAR textLine[1024] = {0}; SafeStrCpy( textLine, buffer, sizeof(textLine) / sizeof(*textLine)); LPCTSTR seperator = " \t#"; LPCTSTR token = _tcstok(buffer, seperator); LPCTSTR comment = "@"; LPCTSTR openMark = "{"; LPCTSTR closeMark = "}"; if(0 == token) { continue; } else if(0 == _tcsnicmp(comment, token, _tcslen(comment))) { continue; } else if(0 == _tcsnicmp(openMark, token, _tcslen(openMark))) { continue; } else if(0 == _tcsnicmp(closeMark, token, _tcslen(closeMark))) { continue; } else if(0 == _tcsicmp("msg", token)) { LPCTSTR textMessageIndex = _tcstok(0, seperator); messageIndex = _ttoi(textMessageIndex ? textMessageIndex : ""); wLineIdx = 0; continue; } // 091216 ShinJS --- Npc_Msg.bin의 Data를 저장(인덱스,라인,메세지) NpcMsgDataKey dataKey( messageIndex, wLineIdx ); m_NpcMsgData.insert( std::make_pair( dataKey, textLine ) ); ++wLineIdx; } }
bool Tokenize() { TCHAR cDIR[MAX_STR_LEN]; GetCurrentDirectory(MAX_STR_LEN, cDIR); _tprintf(_T("%s>>"), cDIR); _getts_s(cmdString); _tcscpy_s(cmdHistory[historyNum++], cmdString); int nowNum = historyNum - 1; while (cmdString[0] == '!') { if (cmdString[1] == '!') { if (_tcslen(cmdString) == 2 && nowNum >= 1) { _tcscpy(cmdString, cmdHistory[nowNum - 1]); nowNum = nowNum - 1; } else { _tprintf(_T("이전 명령어가 존재하지 않습니다.\n")); return false; } } else { int num = SearchToken(); if (num != -1) { _tcscpy(cmdString, cmdHistory[num]); nowNum = num; } else { _tprintf(_T("이전 명령어가 존재하지 않습니다.\n")); return false; } } } _tcscpy_s(cmdCopy, cmdString); TCHAR * token = _tcstok(cmdString, seps); while (token != NULL){ _tcscpy( cmdTokenList[tokenNum++], StrLower(token) ); token = _tcstok(NULL, seps); } return true; }
/** 装载符号定义文件 */ int LoadSymbolData(const TCHAR *file_name) { TCHAR buffer[10 * 1024]; //10K的buffer TCHAR line[0x100]; TCHAR *english_symbol, *chinese_symbol; int char_count; int length, index; int i; if (share_segment->symbol_loaded) return 1; //Copy Default symbol table for (i = 0; i < SYMBOL_NUMBER; i++) _tcscpy(share_segment->symbol_table[i].chinese_symbol, share_segment->symbol_table[i].default_chinese_symbol); if (!(length = LoadFromFile(file_name, buffer, _SizeOf(buffer)))) return 0; index = 1; length = length / sizeof(TCHAR); while(index < length) { //得到一行数据 char_count = 0; while(char_count < _SizeOf(line) - 1 && index < length) { line[char_count++] = buffer[index++]; if (buffer[index - 1] == '\n') break; //遇到回车结束 } line[char_count] = 0; //得到一行数据 //除掉首尾的空白符号 TrimString(line); if (line[0] == '/' && line[1]=='/') //注释行,跳过 continue; english_symbol = _tcstok(line, TEXT(" ")); chinese_symbol = _tcstok(0, TEXT(" ")); if (!english_symbol || !chinese_symbol) continue; //TrimString(english_symbol); //TrimString(chinese_symbol); UpdateSymbol(english_symbol, chinese_symbol); } share_segment->symbol_loaded = 1; return 1; }
CMainWizard::CMainWizard(CWnd* pOwnerWnd): CCustomPropSheet(AFX_IDS_APP_TITLE, pOwnerWnd) { CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp()); ASSERT_VALID(pApp); // assign CRT locale static const TCHAR szDefLocale[] = _T("English_USA.1252"); _tsetlocale(LC_ALL, pApp->GetProfileString(SZ_REGK_LOCALE, SZ_REGV_LOCALE_LC_ALL, szDefLocale)); // load dialog's icons m_hIcon = pApp->LoadIcon(IDI_APP_ICON); m_hSmIcon = pApp->LoadSmIcon(MAKEINTRESOURCE(IDI_APP_ICON)); static HYPERLINKCOLORS linkColors = { RGB(0, 0, 255), // default RGB(0, 0, 255), // active RGB(0, 0, 255), // visited RGB(255, 0, 0) // hover }; CHyperLink::SetColors(linkColors); ATL::CRegKey regKeyLangs; regKeyLangs.Attach(pApp->GetSectionKey(SZ_REGK_LANGUAGES)); int nError = ERROR_SUCCESS; if (static_cast<HKEY>(regKeyLangs) != NULL) { TCHAR szLangNames[128] = { 0 }; ULONG cchNamesMax = _countof(szLangNames); nError = regKeyLangs.QueryStringValue(NULL, szLangNames, &cchNamesMax); if (nError == ERROR_SUCCESS) { LPCTSTR pszSeps = _T(",;\x20"); LPTSTR pszCurLex = _tcstok(szLangNames, pszSeps); while (pszCurLex != NULL) { m_arrLangNames.Add(pszCurLex); pszCurLex = _tcstok(NULL, pszSeps); } } ::RegCloseKey(regKeyLangs.Detach()); } g_fRestartInterface = false; AddPage(&m_pageAbout); AddPage(&m_pageFirstLaunch); AddPage(&m_pageOptions); AddPage(&m_pageFiles); AddPage(&m_pageAction); AddPage(&m_pageProgress); SetWizardMode(); }
void ChangeCurrentDirectory() { if (tokenNum < 2) return; TCHAR * token = _tcstok(cmdCopy, seps); token = _tcstok(NULL, _T("\0")); SetCurrentDirectory(token); }
int LoadConfig(HTTPCSTR UserFile, HTTPCSTR PasswordFile, PCONFIG config) { char line[100]; HTTPCSTR filename = UserFile; if (!filename) filename = PasswordFile; FILE *dataFile = _tfopen(filename, _T("r")); if (dataFile) { if (dataFile) { while (!feof(dataFile)) { memset(line, '\0', sizeof(line)); if (ReadAndSanitizeInput(dataFile, line, sizeof(line) - 1) && (strlen(line) > 1)) { #ifdef _UNICODE HTTPCHAR* lpoutputW = (HTTPCHAR*)malloc(strlen(line) + 1); MultiByteToWideChar(CP_UTF8, 0, line, strlen(line), lpoutputW, strlen(line) + 1); lpoutputW[strlen(line) - 1] = 0; if (UserFile) AddUser(lpoutputW, config); else AddPassword(lpoutputW, config); free(lpoutputW); #else if ((UserFile) && (PasswordFile)) { HTTPCHAR *p = _tcstok(line, _T(":")); if (p) { AddUser(p, config); p = _tcstok(NULL, _T(":")); if (p) { AddPassword(p, config); } else { AddPassword(_T(""), config); } } } else { if (UserFile) AddUser(line, config); else AddPassword(line, config); } #endif } } fclose(dataFile); } } return (1); }
/*! Comment : //******************************************************************/ int CKSMTokenizer::StartParsing(char* szInText, int nInTextLen, char cSP) { //입력값 오류 if(!szInText || nInTextLen < 1) return -1; //기존에 이미 파싱된 결과 있다. if(m_szArrOutText || m_szPlainText) { //EndParsing을 호출하여 기존 파싱된 결과 값을 클리어하고 새로운 파싱을 해야만한다. return -2; } int i = 0; int nSPCount = 0; char szSP[2] = {0x00}; char* p = NULL; szSP[0] = cSP; m_szPlainText = new char[nInTextLen+1]; memset(m_szPlainText, 0x00, nInTextLen+1); memcpy(m_szPlainText, szInText, nInTextLen); for(i = 0; i < nInTextLen; i++) { if(m_szPlainText[i] == szSP[0]) nSPCount++; } //파싱할 구분자가 없다. if(nSPCount < 1) { delete m_szPlainText; m_szPlainText = NULL; return 0; } //파싱된 결과가 저장될 2차원 배열 할당 m_szArrOutText = new char*[nSPCount+1]; memset(m_szArrOutText, 0x00, sizeof(char*) * (nSPCount+1)); p = _tcstok(m_szPlainText, szSP); m_szArrOutText[0] = p; m_nParsingOutCount++; for(i=0; i < nSPCount && p != NULL ; i++) { p = _tcstok(NULL, szSP); if(!p) break; m_szArrOutText[i+1] = p; m_nParsingOutCount++; }/* End of for */ return m_nParsingOutCount; } /* End of Tokenizer */
bool KillProcess() { if (tokenNum < 2) { return false; } TCHAR * token = _tcstok(cmdCopy, seps); token = _tcstok(NULL, _T("\0")); HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hProcessSnap == INVALID_HANDLE_VALUE) { _tprintf(_T("CreateToolhelp32Snapshot error! \n")); return false; } PROCESSENTRY32 pe32; pe32.dwSize = sizeof(PROCESSENTRY32); bool isTerminate = false; if (!Process32First(hProcessSnap, &pe32)) { _tprintf(_T("Process32Fist error! \n")); CloseHandle(hProcessSnap); return false; } do { if (!_tcscmp(pe32.szExeFile, token)) { HANDLE hProcess; hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID); if (hProcess != NULL) { TerminateProcess(hProcess, -1); isTerminate = true; } CloseHandle(hProcess); break; } } while (Process32Next(hProcessSnap, &pe32)); if (isTerminate == false) { _tprintf(_T("Kill Error!\n")); return false; } return true; }
void EchoString() { if (tokenNum < 2) return; TCHAR * token = _tcstok(cmdCopy, seps); token = _tcstok(NULL, _T("\0")); _tprintf(_T("%s\n"), token); }
void showDependents( STRINGLIST *q, // list of dependents STRINGLIST *macros // macros in the dependents ) { char *u, *v; char *w; size_t i; struct _finddata_t finddata; NMHANDLE searchHandle; makeMessage(DEPENDENTS_MESSAGE); for (i = 0; q; q = q->next) { char *szFilename; if (_tcschr(q->text, '$')) { u = expandMacros(q->text, ¯os); for (v = _tcstok(u, " \t"); v; v = _tcstok(NULL, " \t")) { if (_tcspbrk(v, "*?")) { if ((szFilename = findFirst(v, &finddata, &searchHandle))) { do { w = prependPath(v, szFilename); printf("%s ", w); i = checkLineLength(i, w); FREE(w); } while ((szFilename = findNext(&finddata, searchHandle))); } } else { printf("%s ", v); i = checkLineLength(i, v); } } FREE(u); } else if (_tcspbrk(q->text, "*?")) { if ((szFilename = findFirst(q->text, &finddata, &searchHandle))) { do { v = prependPath(q->text, szFilename); printf("%s ", v); i = checkLineLength(i, v); FREE(v); } while ((szFilename = findNext(&finddata, searchHandle))); } } else { printf("%s ", q->text); i = checkLineLength(i, q->text); } } }
//--------------------------------------------------------------------- // すべてのセルを初期化する //--------------------------------------------------------------------- void InitCellsFromFile(SuDokuGame& sudoku, LPCTSTR fname) { while (!g_gameStack.empty()) g_gameStack.pop(); sudoku.InitCells(); FILE* fp = _tfopen(fname, _T("r")); if (fp) { TCHAR buf[512]; for (int y = 0; y < 9; y++) { if (_fgetts(buf, _countof(buf), fp) == NULL) { break; } for (int x = 0; x < 9; x++) { int num = buf[x] - '0'; if (num != 0) { sudoku.FixCell(y, x, num); } } } while (1) { if (_fgetts(buf, _countof(buf), fp) == NULL) { break; } if (_tcsnicmp(_T("ExGroup="), buf, _tcslen(_T("ExGroup="))) == 0) { std::pair<int, int> onePair; std::vector<std::pair<int, int>> oneGroup; LPTSTR p = _tcstok(&buf[_tcslen(_T("ExGroup="))], _T(",")); onePair.first = _tstoi(p); // y 座標 p = _tcstok(NULL, _T(",")); onePair.second = _tstoi(p); // x座標 oneGroup.push_back(onePair); while ((p = _tcstok(NULL, _T(","))) != NULL) { onePair.first = _tstoi(p); p = _tcstok(NULL, _T(",")); onePair.second = _tstoi(p); oneGroup.push_back(onePair); } sudoku.AddExGroup(oneGroup); } } fclose(fp); } }
int get_response_num(const TCHAR *str) { int i = 0; TCHAR *tmp, *strc = NULL; strc = (TCHAR*)malloc((_tcslen(str)+1)*sizeof(TCHAR)); if (strc != NULL) { _tcscpy(strc, str); tmp = _tcstok(strc, L"\r\n"); while(tmp) { i++; tmp = _tcstok(NULL, L"\r\n"); } free(strc); } return i; }
void CShowActiveDirUsers::GetUserAndDomainNameFromUPN(LPTSTR szUser, LPTSTR szUserName, LPTSTR szDomainName) { ULONG size = 8192; TCHAR buffer[8192]; if ( TranslateName( szUser, NameUserPrincipal, NameSamCompatible, buffer, &size ) ) { // we UPN name TCHAR szSeparators[] = L"\\"; TCHAR* szToken = L""; szToken = _tcstok( buffer, szSeparators ); // domain _tcsupr(szToken); _tcscpy(szDomainName, szToken); // user name szToken = wcstok( NULL, szSeparators ); _tcslwr(szToken); _tcscpy(szUserName, szToken); } }
BOOL CreateFolderIfNotFoundDir(LPTSTR strFullPath) { CString strCopyPath = L""; CString strDirectory = L""; WIN32_FIND_DATA findData = {0,}; HANDLE hFind = NULL; TCHAR *pToken = NULL; TCHAR tszSep[] = L"\\"; // 마지막 \\ 문자 다음에는 파일명임 // 폴더만 검색하여, 없는 폴더 생성하기 위해서, 마지막 \\ 이후의 파일명은 포함시키지 않는다. strCopyPath = strFullPath; strCopyPath = strCopyPath.Left(strCopyPath.ReverseFind(L'\\')); pToken = _tcstok( strCopyPath.GetBuffer(), tszSep ); while(pToken) { strDirectory += tszSep; strDirectory += pToken; hFind = FindFirstFile(strDirectory, &findData); if(hFind == INVALID_HANDLE_VALUE) { DWORD dwErr = GetLastError(); if( dwErr == ERROR_PATH_NOT_FOUND || dwErr == ERROR_NO_MORE_FILES ) { if( !CreateDirectory(strDirectory, NULL) ) { FindClose(hFind); return FALSE; } } } FindClose(hFind); pToken = _tcstok( NULL, tszSep ); } return TRUE; }
static void savePatches() { // clear active patch index for (int i = 0; i < MAX_ACTIVE_PATCHES; i++) { _stprintf(szActivePatches[i], _T("")); } int nChecked = 0; int nActivePatches = 0; for (int i = 0; i < nNumPatches; i++) { nChecked = _TreeView_GetCheckState(hIpsList, hPatchHandlesIndex[i]); if (nChecked) { _tcscpy(szActivePatches[nActivePatches], szPatchFileNames[i]); nActivePatches++; if (nActivePatches >= MAX_ACTIVE_PATCHES) { break; } } } FILE* fp = _tfopen(gameIpsConfigName(), _T("wt")); if (fp) { _ftprintf(fp, _T("// ") _T(APP_TITLE) _T(" v%s --- IPS Config File for %s (%hs)\n\n"), szAppBurnVer, BurnDrvGetText(DRV_NAME), BurnDrvGetTextA(DRV_FULLNAME)); TCHAR szPatchName[MAX_PATH]; TCHAR szFileName[MAX_PATH]; TCHAR* Tokens = NULL; for (int i = 0; i < nActivePatches; i++) { _tcscpy(szPatchName, szActivePatches[i]); // make a copy, modified by regret Tokens = _tcstok(szPatchName, _T("\\")); while (Tokens != NULL) { szFileName[0] = _T('\0'); _tcscpy(szFileName, Tokens); Tokens = _tcstok(NULL, _T("\\")); } _ftprintf(fp, _T("%s\n"), szFileName); } fclose(fp); } // if no active patch, delete config file if (nActivePatches == 0) { _tremove(gameIpsConfigName()); } }