bool Workspace::CheckAppLogFilter(const char* filter) { if (Config::IsSocketing()) { //m_applogFilter is UPPER if (!m_applogFilter.empty()) { if (m_applogFilter == "ALL") { return true; } else { behaviac::string f = filter; f = make_upper(f); if (m_applogFilter == f) { return true; } } } } return false; }
static int set_rexx_variable( char *name, int suffix, char *value, int value_length ) { SHVBLOCK shv; char variable_name[250]; int rc=0; shv.shvnext=NULL; /* only one block */ shv.shvcode=RXSHV_SET; /* use direct set */ sprintf( variable_name, "%s.%-d", name, suffix ); (void)make_upper( variable_name );/* make variable name uppercase */ /* * Now (attempt to) set the REXX variable * Add name/value to SHVBLOCK */ MAKERXSTRING( shv.shvname, variable_name, strlen( variable_name) ); MAKERXSTRING( shv.shvvalue, value, value_length ); /* * One or both of these is needed, too <sigh> */ shv.shvnamelen = strlen( variable_name ); shv.shvvaluelen = value_length; rc = RexxVariablePool( &shv ); /* Set the REXX variable */ if ( rc != RXSHV_OK && rc != RXSHV_NEWV) { rc = 1; } else rc = 0; return rc; }
inline S to_upper(S const& s) { S r(s); make_upper(r); return r; }
//************************************************************************** // GetServiceName() looks up service by application path. If found, the function // fills pszServiceName (must be at least 256+1 characters long). bool GetServiceName(TCHAR *pszAppPath, TCHAR *pszServiceName) { // prepare given application path for matching against service list std::string appPath(pszAppPath); // convert to uppercase make_upper(appPath); // connect to serice control manager SC_HANDLE hManager = OpenSCManager(NULL, NULL, SC_MANAGER_ENUMERATE_SERVICE); if (!hManager) return false; DWORD dwBufferSize = 0; DWORD dwCount = 0; DWORD dwPosition = 0; bool bResult = false; // call EnumServicesStatus() the first time to receive services array size BOOL bOK = EnumServicesStatus( hManager, SERVICE_WIN32, SERVICE_STATE_ALL, NULL, 0, &dwBufferSize, &dwCount, &dwPosition); if (!bOK && GetLastError() == ERROR_MORE_DATA) { // allocate space per results from the first call ENUM_SERVICE_STATUS *pServices = (ENUM_SERVICE_STATUS *) new UCHAR[dwBufferSize]; if (pServices) { // call EnumServicesStatus() the second time to actually get the services array bOK = EnumServicesStatus( hManager, SERVICE_WIN32, SERVICE_STATE_ALL, pServices, dwBufferSize, &dwBufferSize, &dwCount, &dwPosition); if (bOK) { // iterate through all services returned by EnumServicesStatus() for (DWORD i = 0; i < dwCount && !bResult; i++) { // open service SC_HANDLE hService = OpenService(hManager, pServices[i].lpServiceName, GENERIC_READ); if (!hService) break; // call QueryServiceConfig() the first time to receive buffer size bOK = QueryServiceConfig( hService, NULL, 0, &dwBufferSize); if (!bOK && GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // allocate space per results from the first call QUERY_SERVICE_CONFIG *pServiceConfig = (QUERY_SERVICE_CONFIG *) new UCHAR[dwBufferSize]; if (pServiceConfig) { // call EnumServicesStatus() the second time to actually get service config bOK = QueryServiceConfig( hService, pServiceConfig, dwBufferSize, &dwBufferSize); if (bOK) { // match given application name against executable path in the service config std::string servicePath(pServiceConfig->lpBinaryPathName); make_upper(servicePath); if (servicePath.find(appPath.c_str()) != -1) { bResult = true; strncpy(pszServiceName, pServices[i].lpServiceName, 256); pszServiceName[255] = 0; } } delete [] (UCHAR *) pServiceConfig; } } CloseServiceHandle(hService); } } delete [] (UCHAR *) pServices; } } // disconnect from serice control manager CloseServiceHandle(hManager); return bResult; }
static void make_string_upper(char *str) { char *ptr; for (ptr = str; *ptr; ptr++) *ptr = make_upper(*ptr); } /* make_string_upper */