这篇教程C++ wcschr函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中wcschr函数的典型用法代码示例。如果您正苦于以下问题:C++ wcschr函数的具体用法?C++ wcschr怎么用?C++ wcschr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了wcschr函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: ProcessBufferint ProcessBuffer(unsigned char* buffer, const char *section, const CONFENTRY *entrydef, const int entrycount, int* result, unsigned char* config, int maxbufsize){ int done = FALSE; int len; if (TestBuffer(buffer)==UTF_16) { //TODO Do wide char with the ANSI wchar_t *result1, *result2; result1 = (wchar_t*)buffer; if (section!=NULL) { //TODO Find a solution to the problem of different charactersets //result1 = FindSectionW(result1, section); if (result2==NULL) return NO_SECTION; result2 = FindSectionEndW(result1); if (result2!=NULL) result2[0] = 0; } while(!done) { result1 = wcschr(result1, L'*'); if (result1!=NULL) { //TODO maybe do more checks result1+=1; result2 = wcschr(result1, L'='); if (result2!=NULL) { *result2 = 0; result2++; } else done = TRUE; result1 = ProcessKeyW(entrydef, entrycount, result, result1, result2, config); if (result1==NULL) done = TRUE; } } } else { char *result1, *result2; result1 = (char*)buffer; if (section != NULL) { result1 = FindSectionA(result1, section, NULL); if (result2==NULL) return NO_SECTION; result2 = FindSectionEndA(result1); if (result2 != NULL) result2[0] = 0; } /* Processes every key - a key starts with a * and ends with a = till it reaches the end of the buffer - or there is no data to be processed The key should be in ASCII - for highes compatibility */ while(!done) { result1 = strchr(result1, L'*'); if (result1!=NULL) { //TODO maybe do more checks if (result1[-1]=='/n') { result1+=1; result2 = strchr(result1, L'='); if (result2!=NULL) { *result2 = 0; result2++; } else done = TRUE; result1 = ProcessKeyA(entrydef, entrycount, result, own_strtolower(result1), result2, config); if (result1==NULL) done = TRUE; } else result1++; } else break; } } return 0;}
开发者ID:thgr64,项目名称:gexconf,代码行数:93,
示例2: CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_fprintf_68_badvoid CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_fprintf_68_bad(){ wchar_t * data; wchar_t dataBuffer[100] = L""; data = dataBuffer; {#ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0;#endif int recvResult; struct sockaddr_in service; wchar_t *replace; SOCKET connectSocket = INVALID_SOCKET; size_t dataLen = wcslen(data); do {#ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { break; } wsaDataInit = 1;#endif /* POTENTIAL FLAW: Read data using a connect socket */ connectSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (connectSocket == INVALID_SOCKET) { break; } memset(&service, 0, sizeof(service)); service.sin_family = AF_INET; service.sin_addr.s_addr = inet_addr(IP_ADDRESS); service.sin_port = htons(TCP_PORT); if (connect(connectSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR) { break; } /* Abort on error or the connection was closed, make sure to recv one * less char than is in the recv_buf in order to append a terminator */ /* Abort on error or the connection was closed */ recvResult = recv(connectSocket, (char *)(data + dataLen), sizeof(wchar_t) * (100 - dataLen - 1), 0); if (recvResult == SOCKET_ERROR || recvResult == 0) { break; } /* Append null terminator */ data[dataLen + recvResult / sizeof(wchar_t)] = L'/0'; /* Eliminate CRLF */ replace = wcschr(data, L'/r'); if (replace) { *replace = L'/0'; } replace = wcschr(data, L'/n'); if (replace) { *replace = L'/0'; } } while (0); if (connectSocket != INVALID_SOCKET) { CLOSE_SOCKET(connectSocket); }#ifdef _WIN32 if (wsaDataInit) { WSACleanup(); }#endif } CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_fprintf_68_badData = data; CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_fprintf_68b_badSink();}
开发者ID:maurer,项目名称:tiamat,代码行数:75,
示例3: wWinMain/* * The main function implements a loader for applications which use UNO. * * <p>This code runs on the Windows platform only.</p> * * <p>The main function detects a UNO installation on the system and adds the * program directory of the UNO installation to the PATH environment variable. * After that, the application process is loaded and started, whereby the * new process inherits the environment of the calling process, including * the modified PATH environment variable. The application's executable name * must be the same as the name of this executable, prefixed by '_'.</p> * * <p>A UNO installation can be specified by the user by setting the UNO_PATH * environment variable to the program directory of the UNO installation. * If no installation is specified by the user, the default installation on * the system will be taken. The default installation is read from the * default value of the key "Software/LibreOffice/UNO/InstallPath" from the * root key HKEY_CURRENT_USER in the Windows Registry. If this key is missing, * the key is read from the root key HKEY_LOCAL_MACHINE.</p> */int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow ){ (void) hInstance; /* unused */ (void) hPrevInstance; /* unused */ (void) nCmdShow; /* unused */ /* get the path of the UNO installation */ wchar_t* path = getPath(); if ( path != NULL ) { wchar_t cmd[ MY_LENGTH(L"/"") + MAX_PATH + MY_LENGTH(L"//unoinfo.exe/" c++")]; /* hopefully does not overflow */ cmd[0] = L'"'; wcscpy(cmd + 1, path); if (wcschr(cmd + 1, L'"') != NULL) { free(path); writeError("Error: bad characters in UNO installation path!/n"); closeErrorFile(); return 1; } size_t pathsize = wcslen(cmd); wcscpy( cmd + pathsize, &L"//unoinfo.exe/" c++"[ pathsize == 1 || cmd[pathsize - 1] != L'//' ? 0 : 1]); SECURITY_ATTRIBUTES sec; sec.nLength = sizeof (SECURITY_ATTRIBUTES); sec.lpSecurityDescriptor = NULL; sec.bInheritHandle = TRUE; HANDLE stdoutRead; HANDLE stdoutWrite; HANDLE temp; if (CreatePipe(&temp, &stdoutWrite, &sec, 0) == 0 || DuplicateHandle( GetCurrentProcess(), temp, GetCurrentProcess(), &stdoutRead, 0, FALSE, DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS) == 0) { free(path); writeError("Error: CreatePipe/DuplicateHandle failed!/n"); closeErrorFile(); return 1; } STARTUPINFOW startinfo; PROCESS_INFORMATION procinfo; memset(&startinfo, 0, sizeof(startinfo)); startinfo.cb = sizeof(startinfo); startinfo.lpDesktop = L""; startinfo.dwFlags = STARTF_USESTDHANDLES; startinfo.hStdOutput = stdoutWrite; BOOL ret = CreateProcessW( NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &startinfo, &procinfo); if (ret != FALSE) { // Release result of GetPath() free(path); char * buf = NULL; char * tmp; DWORD n = 1000; DWORD k = 0; DWORD exitcode; CloseHandle(stdoutWrite); CloseHandle(procinfo.hThread); for (;;) { DWORD m; tmp = realloc(buf, n); if (tmp == NULL) { free(buf); writeError( "Error: out of memory reading unoinfo output!/n"); closeErrorFile(); return 1; } buf = tmp; if (!ReadFile(stdoutRead, buf + k, n - k, &m, NULL)) { DWORD err = GetLastError();//.........这里部分代码省略.........
开发者ID:chrissherlock,项目名称:libreoffice-experimental,代码行数:101,
示例4: badvoid bad(){ wchar_t * data; wchar_t dataBuffer[FILENAME_MAX] = BASEPATH; data = dataBuffer; if(GLOBAL_CONST_FIVE==5) { {#ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0;#endif int recvResult; struct sockaddr_in service; wchar_t *replace; SOCKET listenSocket = INVALID_SOCKET; SOCKET acceptSocket = INVALID_SOCKET; size_t dataLen = wcslen(data); do {#ifdef _WIN32 if (WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) { break; } wsaDataInit = 1;#endif /* POTENTIAL FLAW: Read data using a listen socket */ listenSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (listenSocket == INVALID_SOCKET) { break; } memset(&service, 0, sizeof(service)); service.sin_family = AF_INET; service.sin_addr.s_addr = INADDR_ANY; service.sin_port = htons(TCP_PORT); if (bind(listenSocket, (struct sockaddr*)&service, sizeof(service)) == SOCKET_ERROR) { break; } if (listen(listenSocket, LISTEN_BACKLOG) == SOCKET_ERROR) { break; } acceptSocket = accept(listenSocket, NULL, NULL); if (acceptSocket == SOCKET_ERROR) { break; } /* Abort on error or the connection was closed */ recvResult = recv(acceptSocket, (char *)(data + dataLen), sizeof(wchar_t) * (FILENAME_MAX - dataLen - 1), 0); if (recvResult == SOCKET_ERROR || recvResult == 0) { break; } /* Append null terminator */ data[dataLen + recvResult / sizeof(wchar_t)] = L'/0'; /* Eliminate CRLF */ replace = wcschr(data, L'/r'); if (replace) { *replace = L'/0'; } replace = wcschr(data, L'/n'); if (replace) { *replace = L'/0'; } } while (0); if (listenSocket != INVALID_SOCKET) { CLOSE_SOCKET(listenSocket); } if (acceptSocket != INVALID_SOCKET) { CLOSE_SOCKET(acceptSocket); }#ifdef _WIN32 if (wsaDataInit) { WSACleanup(); }#endif } } { ifstream inputFile; /* POTENTIAL FLAW: Possibly opening a file without validating the file name or path */ inputFile.open((char *)data); inputFile.close(); }}
开发者ID:maurer,项目名称:tiamat,代码行数:94,
示例5: zabbix_log/****************************************************************************** * * * Function: zbx_win_getversion * * * * Purpose: get Windows version information * * * ******************************************************************************/const OSVERSIONINFOEX *zbx_win_getversion(){# define ZBX_REGKEY_VERSION "SOFTWARE//Microsoft//Windows NT//CurrentVersion"# define ZBX_REGVALUE_CURRENTVERSION "CurrentVersion"# define ZBX_REGVALUE_CURRENTBUILDNUMBER "CurrentBuildNumber"# define ZBX_REGVALUE_CSDVERSION "CSDVersion"# define ZBX_REGKEY_PRODUCT "System//CurrentControlSet//Control//ProductOptions"# define ZBX_REGVALUE_PRODUCTTYPE "ProductType" static OSVERSIONINFOEX vi = {sizeof(OSVERSIONINFOEX)}; OSVERSIONINFOEX *pvi = NULL; HKEY h_key_registry = NULL; wchar_t *key_value = NULL, *ptr; if (0 != vi.dwMajorVersion) return &vi; if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT(ZBX_REGKEY_VERSION), 0, KEY_READ, &h_key_registry)) { zabbix_log(LOG_LEVEL_DEBUG, "failed to open registry key '%s'", ZBX_REGKEY_VERSION); goto out; } if (NULL == (key_value = read_registry_value(h_key_registry, TEXT(ZBX_REGVALUE_CURRENTVERSION)))) { zabbix_log(LOG_LEVEL_DEBUG, "failed to read registry value '%s'", ZBX_REGVALUE_CURRENTVERSION); goto out; } if (NULL != (ptr = wcschr(key_value, TEXT('.')))) { *ptr++ = L'/0'; vi.dwMinorVersion = _wtoi(ptr); } vi.dwMajorVersion = _wtoi(key_value); zbx_free(key_value); if (6 > vi.dwMajorVersion || 2 > vi.dwMinorVersion) { GetVersionEx((OSVERSIONINFO *)&vi); } else { if (NULL != (key_value = read_registry_value(h_key_registry, TEXT(ZBX_REGVALUE_CSDVERSION)))) { wcscpy_s(vi.szCSDVersion, sizeof(vi.szCSDVersion) / sizeof(*vi.szCSDVersion), key_value); zbx_free(key_value); } if (NULL == (key_value = read_registry_value(h_key_registry, TEXT(ZBX_REGVALUE_CURRENTBUILDNUMBER)))) { zabbix_log(LOG_LEVEL_DEBUG, "failed to read registry value '%s'", ZBX_REGVALUE_CURRENTBUILDNUMBER); goto out; } vi.dwBuildNumber = _wtoi(key_value); zbx_free(key_value); RegCloseKey(h_key_registry); h_key_registry = NULL; if (ERROR_SUCCESS != RegOpenKeyEx(HKEY_LOCAL_MACHINE, TEXT(ZBX_REGKEY_PRODUCT), 0, KEY_READ, &h_key_registry)) { zabbix_log(LOG_LEVEL_DEBUG, "failed to open registry key '%s'", ZBX_REGKEY_PRODUCT); goto out; } if (NULL == (key_value = read_registry_value(h_key_registry, TEXT(ZBX_REGVALUE_PRODUCTTYPE)))) { zabbix_log(LOG_LEVEL_DEBUG, "failed to read registry value '%s'", ZBX_REGVALUE_PRODUCTTYPE); goto out; } if (0 == wcscmp(key_value, L"WinNT")) vi.wProductType = 1; else if (0 == wcscmp(key_value, L"LenmanNT")) vi.wProductType = 2; else if (0 == wcscmp(key_value, L"ServerNT")) vi.wProductType = 3; zbx_free(key_value); vi.dwPlatformId = VER_PLATFORM_WIN32_NT; } pvi = &vi;//.........这里部分代码省略.........
开发者ID:B5r1oJ0A9G,项目名称:zabbix-patches,代码行数:101,
示例6: vfatIsLongIllegalBOOLEANvfatIsLongIllegal(WCHAR c){ return wcschr(long_illegals, c) ? TRUE : FALSE;}
开发者ID:RareHare,项目名称:reactos,代码行数:5,
示例7: DrvLetterToIndexint DriveMng::SetDriveID(const WCHAR *_root){ if (!_root || !_root[0]) return -1; WCHAR root[MAX_PATH]; int idx = -1; ::CharUpperW(wcscpy(root, _root)); if (root[1] == ':') { idx = DrvLetterToIndex(root[0]); if (idx < 0 || idx >= MAX_LOCAL_DRIVES) return -1; } else { // ネットワ C++ wcscpy_c函数代码示例 C++ wcscat_c函数代码示例
|