int __cdecl GCMenuHook(WPARAM wParam,LPARAM lParam) { GCMENUITEMS *gcmi= (GCMENUITEMS*) lParam; DBVARIANT dbv; TCHAR* szInvite = TranslateT("&Invite user..."); TCHAR* szLeave = TranslateT("&Leave chat session"); TCHAR* szTopic = TranslateT("Set &Topic..."); TCHAR* szDetails = TranslateT("User &details"); TCHAR* szHistory = TranslateT("User &history"); TCHAR* szKick = TranslateT("&Kick user"); static struct gc_item Item_log[] = { {NULL, 10, MENU_ITEM, FALSE}, {NULL, 30, MENU_ITEM, FALSE}, {NULL, 20, MENU_ITEM, FALSE} }; static struct gc_item Item_nicklist_me[] = { {NULL, 20, MENU_ITEM, FALSE}, {_T(""), 100, MENU_SEPARATOR, FALSE}, {NULL, 110, MENU_ITEM, FALSE} }; static struct gc_item Item_nicklist[] = { {NULL, 10, MENU_ITEM, FALSE}, {NULL, 20, MENU_ITEM, FALSE}, {NULL, 30, MENU_ITEM, FALSE} }; UNREFERENCED_PARAMETER(wParam); Item_log[0].pszDesc = szInvite; Item_log[1].pszDesc = szTopic; Item_log[2].pszDesc = szLeave; Item_nicklist_me[0].pszDesc = szHistory; Item_nicklist_me[2].pszDesc = szLeave; Item_nicklist[0].pszDesc = szDetails; Item_nicklist[1].pszDesc = szHistory; Item_nicklist[2].pszDesc = szKick; LOG (("GCMenuHook started.")); if(gcmi) { if (!_stricmp(gcmi->pszModule, SKYPE_PROTONAME)) { switch (gcmi->Type) { case MENU_ON_LOG: gcmi->nItems = sizeof(Item_log)/sizeof(Item_log[0]); gcmi->Item = &Item_log[0]; LOG (("GCMenuHook: Items in log window: %d", gcmi->nItems)); break; case MENU_ON_NICKLIST: if (db_get_ts(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv)) return -1; if (!lstrcmp(dbv.ptszVal, gcmi->pszUID)) { gcmi->nItems = sizeof(Item_nicklist_me)/sizeof(Item_nicklist_me[0]); gcmi->Item = &Item_nicklist_me[0]; } else { gchat_contacts *gcs = GetChat(gcmi->pszID); gchat_contact *gc = gcs?GetChatContact(gcs, gcmi->pszUID):NULL; gcmi->nItems = sizeof(Item_nicklist)/sizeof(Item_nicklist[0]); Item_nicklist[2].bDisabled = FALSE; if (gc && !gc->hContact) { gcmi->nItems -= 2; gcmi->Item = &Item_nicklist[2]; } else gcmi->Item = &Item_nicklist[0]; /* if (protocol<7) Item_nicklist[2].bDisabled = TRUE; else { TCHAR *szChatRole; if (szChatRole = SkypeGetT ("CHAT", gcmi->pszID, "MYROLE")) { if (_tcscmp(szChatRole, _T("MASTER")) && _tcscmp(szChatRole, _T("CREATOR"))) Item_nicklist[2].bDisabled = TRUE; free (szChatRole); } }*/ } db_free(&dbv); break; } } else {LOG (("GCMenuHook: ERROR: Not our protocol."));} } else {LOG (("GCMenuHook: ERROR: No gcmi"));} LOG (("GCMenuHook: terminated.")); return 0; }
BOOL freerdp_client_rdp_file_set_integer(rdpFile* file, const char* name, int value, int index) { BOOL bStandard = TRUE; #ifdef DEBUG_CLIENT_FILE fprintf(stderr, "%s:i:%d\n", name, value); #endif if (_stricmp(name, "use multimon") == 0) file->UseMultiMon = value; else if (_stricmp(name, "screen mode id") == 0) file->ScreenModeId = value; else if (_stricmp(name, "span monitors") == 0) file->SpanMonitors = value; else if (_stricmp(name, "smart sizing") == 0) file->SmartSizing = value; else if (_stricmp(name, "enablesuperpan") == 0) file->EnableSuperSpan = value; else if (_stricmp(name, "superpanaccelerationfactor") == 0) file->SuperSpanAccelerationFactor = value; else if (_stricmp(name, "desktopwidth") == 0) file->DesktopWidth = value; else if (_stricmp(name, "desktopheight") == 0) file->DesktopHeight = value; else if (_stricmp(name, "desktop size id") == 0) file->DesktopSizeId = value; else if (_stricmp(name, "session bpp") == 0) file->SessionBpp = value; else if (_stricmp(name, "compression") == 0) file->Compression = value; else if (_stricmp(name, "keyboardhook") == 0) file->KeyboardHook = value; else if (_stricmp(name, "disable ctrl+alt+del") == 0) file->DisableCtrlAltDel = value; else if (_stricmp(name, "audiomode") == 0) file->AudioMode = value; else if (_stricmp(name, "audioqualitymode") == 0) file->AudioQualityMode = value; else if (_stricmp(name, "audiocapturemode") == 0) file->AudioCaptureMode = value; else if (_stricmp(name, "videoplaybackmode") == 0) file->VideoPlaybackMode = value; else if (_stricmp(name, "connection type") == 0) file->ConnectionType = value; else if (_stricmp(name, "networkautodetect") == 0) file->NetworkAutoDetect = value; else if (_stricmp(name, "bandwidthautodetect") == 0) file->BandwidthAutoDetect = value; else if (_stricmp(name, "pinconnectionbar") == 0) file->PinConnectionBar = value; else if (_stricmp(name, "displayconnectionbar") == 0) file->DisplayConnectionBar = value; else if (_stricmp(name, "workspaceid") == 0) file->WorkspaceId = value; else if (_stricmp(name, "enableworkspacereconnect") == 0) file->EnableWorkspaceReconnect = value; else if (_stricmp(name, "disable wallpaper") == 0) file->DisableWallpaper = value; else if (_stricmp(name, "allow font smoothing") == 0) file->AllowFontSmoothing = value; else if (_stricmp(name, "allow desktop composition") == 0) file->AllowDesktopComposition = value; else if (_stricmp(name, "disable full window drag") == 0) file->DisableFullWindowDrag = value; else if (_stricmp(name, "disable menu anims") == 0) file->DisableMenuAnims = value; else if (_stricmp(name, "disable themes") == 0) file->DisableThemes = value; else if (_stricmp(name, "disable cursor setting") == 0) file->DisableCursorSetting = value; else if (_stricmp(name, "bitmapcachesize") == 0) file->BitmapCacheSize = value; else if (_stricmp(name, "bitmapcachepersistenable") == 0) file->BitmapCachePersistEnable = value; else if (_stricmp(name, "server port") == 0) file->ServerPort = value; else if (_stricmp(name, "redirectdrives") == 0) file->RedirectDrives = value; else if (_stricmp(name, "redirectprinters") == 0) file->RedirectPrinters = value; else if (_stricmp(name, "redirectcomports") == 0) file->RedirectComPorts = value; else if (_stricmp(name, "redirectsmartcards") == 0) file->RedirectSmartCards = value; else if (_stricmp(name, "redirectclipboard") == 0) file->RedirectClipboard = value; else if (_stricmp(name, "redirectposdevices") == 0) file->RedirectPosDevices = value; else if (_stricmp(name, "redirectdirectx") == 0) file->RedirectDirectX = value; else if (_stricmp(name, "disableprinterredirection") == 0) file->DisablePrinterRedirection = value; else if (_stricmp(name, "disableclipboardredirection") == 0) file->DisableClipboardRedirection = value; else if (_stricmp(name, "connect to console") == 0) file->ConnectToConsole = value; else if (_stricmp(name, "administrative session") == 0) file->AdministrativeSession = value; else if (_stricmp(name, "autoreconnection enabled") == 0) file->AutoReconnectionEnabled = value; else if (_stricmp(name, "autoreconnect max retries") == 0) file->AutoReconnectMaxRetries = value; else if (_stricmp(name, "public mode") == 0) file->PublicMode = value; else if (_stricmp(name, "authentication level") == 0) file->AuthenticationLevel = value; else if (_stricmp(name, "promptcredentialonce") == 0) file->PromptCredentialOnce = value; else if (_stricmp(name, "prompt for credentials") == 0) file->PromptForCredentials = value; else if (_stricmp(name, "promptcredentialonce") == 0) file->PromptForCredentialsOnce = value; else if (_stricmp(name, "negotiate security layer") == 0) file->NegotiateSecurityLayer = value; else if (_stricmp(name, "enablecredsspsupport") == 0) file->EnableCredSSPSupport = value; else if (_stricmp(name, "remoteapplicationmode") == 0) file->RemoteApplicationMode = value; else if (_stricmp(name, "remoteapplicationexpandcmdline") == 0) file->RemoteApplicationExpandCmdLine = value; else if (_stricmp(name, "remoteapplicationexpandworkingdir") == 0) file->RemoteApplicationExpandWorkingDir = value; else if (_stricmp(name, "disableconnectionsharing") == 0) file->DisableConnectionSharing = value; else if (_stricmp(name, "disableremoteappcapscheck") == 0) file->DisableRemoteAppCapsCheck = value; else if (_stricmp(name, "gatewayusagemethod") == 0) file->GatewayUsageMethod = value; else if (_stricmp(name, "gatewayprofileusagemethod") == 0) file->GatewayProfileUsageMethod = value; else if (_stricmp(name, "gatewaycredentialssource") == 0) file->GatewayCredentialsSource = value; else if (_stricmp(name, "use redirection server name") == 0) file->UseRedirectionServerName = value; else if (_stricmp(name, "rdgiskdcproxy") == 0) file->RdgIsKdcProxy = value; else bStandard = FALSE; if (index >= 0) { file->lines[index].name = _strdup(name); file->lines[index].iValue = (DWORD) value; file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED; file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_INTEGER; if (bStandard) file->lines[index].flags |= RDP_FILE_LINE_FLAG_STANDARD; file->lines[index].valueLength = 0; } return bStandard; }
int rpl_stat (char const *name, struct stat *buf) { #ifdef WINDOWS_NATIVE /* Fill the fields ourselves, because the original stat function returns values for st_atime, st_mtime, st_ctime that depend on the current time zone. See <https://lists.gnu.org/r/bug-gnulib/2017-04/msg00134.html> */ /* XXX Should we convert to wchar_t* and prepend '\\?\', in order to work around length limitations <https://msdn.microsoft.com/en-us/library/aa365247.aspx> ? */ /* POSIX <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13> specifies: "More than two leading <slash> characters shall be treated as a single <slash> character." */ if (ISSLASH (name[0]) && ISSLASH (name[1]) && ISSLASH (name[2])) { name += 2; while (ISSLASH (name[1])) name++; } size_t len = strlen (name); size_t drive_prefix_len = (HAS_DEVICE (name) ? 2 : 0); /* Remove trailing slashes (except the very first one, at position drive_prefix_len), but remember their presence. */ size_t rlen; bool check_dir = false; rlen = len; while (rlen > drive_prefix_len && ISSLASH (name[rlen-1])) { check_dir = true; if (rlen == drive_prefix_len + 1) break; rlen--; } /* Handle '' and 'C:'. */ if (!check_dir && rlen == drive_prefix_len) { errno = ENOENT; return -1; } /* Handle '\\'. */ if (rlen == 1 && ISSLASH (name[0]) && len >= 2) { errno = ENOENT; return -1; } const char *rname; char *malloca_rname; if (rlen == len) { rname = name; malloca_rname = NULL; } else { malloca_rname = malloca (rlen + 1); if (malloca_rname == NULL) { errno = ENOMEM; return -1; } memcpy (malloca_rname, name, rlen); malloca_rname[rlen] = '\0'; rname = malloca_rname; } /* There are two ways to get at the requested information: - by scanning the parent directory and examining the relevant directory entry, - by opening the file directly. The first approach fails for root directories (e.g. 'C:\') and UNC root directories (e.g. '\\server\share'). The second approach fails for some system files (e.g. 'C:\pagefile.sys' and 'C:\hiberfil.sys'): ERROR_SHARING_VIOLATION. The second approach gives more information (in particular, correct st_dev, st_ino, st_nlink fields). So we use the second approach and, as a fallback except for root and UNC root directories, also the first approach. */ { int ret; { /* Approach based on the file. */ /* Open a handle to the file. CreateFile <https://msdn.microsoft.com/en-us/library/aa363858.aspx> <https://msdn.microsoft.com/en-us/library/aa363874.aspx> */ HANDLE h = CreateFile (rname, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, /* FILE_FLAG_POSIX_SEMANTICS (treat file names that differ only in case as different) makes sense only when applied to *all* filesystem operations. */ FILE_FLAG_BACKUP_SEMANTICS /* | FILE_FLAG_POSIX_SEMANTICS */, NULL); if (h != INVALID_HANDLE_VALUE) { ret = _gl_fstat_by_handle (h, rname, buf); CloseHandle (h); goto done; } } /* Test for root and UNC root directories. */ if ((rlen == drive_prefix_len + 1 && ISSLASH (rname[drive_prefix_len])) || is_unc_root (rname)) goto failed; /* Fallback. */ { /* Approach based on the directory entry. */ if (strchr (rname, '?') != NULL || strchr (rname, '*') != NULL) { /* Other Windows API functions would fail with error ERROR_INVALID_NAME. */ if (malloca_rname != NULL) freea (malloca_rname); errno = ENOENT; return -1; } /* Get the details about the directory entry. This can be done through FindFirstFile <https://msdn.microsoft.com/en-us/library/aa364418.aspx> <https://msdn.microsoft.com/en-us/library/aa365740.aspx> or through FindFirstFileEx with argument FindExInfoBasic <https://msdn.microsoft.com/en-us/library/aa364419.aspx> <https://msdn.microsoft.com/en-us/library/aa364415.aspx> <https://msdn.microsoft.com/en-us/library/aa365740.aspx> */ WIN32_FIND_DATA info; HANDLE h = FindFirstFile (rname, &info); if (h == INVALID_HANDLE_VALUE) goto failed; /* Test for error conditions before starting to fill *buf. */ if (sizeof (buf->st_size) <= 4 && info.nFileSizeHigh > 0) { FindClose (h); if (malloca_rname != NULL) freea (malloca_rname); errno = EOVERFLOW; return -1; } # if _GL_WINDOWS_STAT_INODES buf->st_dev = 0; # if _GL_WINDOWS_STAT_INODES == 2 buf->st_ino._gl_ino[0] = buf->st_ino._gl_ino[1] = 0; # else /* _GL_WINDOWS_STAT_INODES == 1 */ buf->st_ino = 0; # endif # else /* st_ino is not wide enough for identifying a file on a device. Without st_ino, st_dev is pointless. */ buf->st_dev = 0; buf->st_ino = 0; # endif /* st_mode. */ unsigned int mode = /* XXX How to handle FILE_ATTRIBUTE_REPARSE_POINT ? */ ((info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ? _S_IFDIR | S_IEXEC_UGO : _S_IFREG) | S_IREAD_UGO | ((info.dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? 0 : S_IWRITE_UGO); if (!(info.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { /* Determine whether the file is executable by looking at the file name suffix. */ if (info.nFileSizeHigh > 0 || info.nFileSizeLow > 0) { const char *last_dot = NULL; const char *p; for (p = info.cFileName; *p != '\0'; p++) if (*p == '.') last_dot = p; if (last_dot != NULL) { const char *suffix = last_dot + 1; if (_stricmp (suffix, "exe") == 0 || _stricmp (suffix, "bat") == 0 || _stricmp (suffix, "cmd") == 0 || _stricmp (suffix, "com") == 0) mode |= S_IEXEC_UGO; } } } buf->st_mode = mode; /* st_nlink. Ignore hard links here. */ buf->st_nlink = 1; /* There's no easy way to map the Windows SID concept to an integer. */ buf->st_uid = 0; buf->st_gid = 0; /* st_rdev is irrelevant for normal files and directories. */ buf->st_rdev = 0; /* st_size. */ if (sizeof (buf->st_size) <= 4) /* Range check already done above. */ buf->st_size = info.nFileSizeLow; else buf->st_size = ((long long) info.nFileSizeHigh << 32) | (long long) info.nFileSizeLow; /* st_atime, st_mtime, st_ctime. */ # if _GL_WINDOWS_STAT_TIMESPEC buf->st_atim = _gl_convert_FILETIME_to_timespec (&info.ftLastAccessTime); buf->st_mtim = _gl_convert_FILETIME_to_timespec (&info.ftLastWriteTime); buf->st_ctim = _gl_convert_FILETIME_to_timespec (&info.ftCreationTime); # else buf->st_atime = _gl_convert_FILETIME_to_POSIX (&info.ftLastAccessTime); buf->st_mtime = _gl_convert_FILETIME_to_POSIX (&info.ftLastWriteTime); buf->st_ctime = _gl_convert_FILETIME_to_POSIX (&info.ftCreationTime); # endif FindClose (h); ret = 0; } done: if (ret >= 0 && check_dir && !S_ISDIR (buf->st_mode)) { errno = ENOTDIR; ret = -1; } if (malloca_rname != NULL) { int saved_errno = errno; freea (malloca_rname); errno = saved_errno; } return ret; } failed: { DWORD error = GetLastError (); #if 0 fprintf (stderr, "rpl_stat error 0x%x\n", (unsigned int) error); #endif if (malloca_rname != NULL) freea (malloca_rname); switch (error) { /* Some of these errors probably cannot happen with the specific flags that we pass to CreateFile. But who knows... */ case ERROR_FILE_NOT_FOUND: /* The last component of rname does not exist. */ case ERROR_PATH_NOT_FOUND: /* Some directory component in rname does not exist. */ case ERROR_BAD_PATHNAME: /* rname is such as '\\server'. */ case ERROR_BAD_NET_NAME: /* rname is such as '\\server\nonexistentshare'. */ case ERROR_INVALID_NAME: /* rname contains wildcards, misplaced colon, etc. */ case ERROR_DIRECTORY: errno = ENOENT; break; case ERROR_ACCESS_DENIED: /* rname is such as 'C:\System Volume Information\foo'. */ case ERROR_SHARING_VIOLATION: /* rname is such as 'C:\pagefile.sys' (second approach only). */ /* XXX map to EACCESS or EPERM? */ errno = EACCES; break; case ERROR_OUTOFMEMORY: errno = ENOMEM; break; case ERROR_WRITE_PROTECT: errno = EROFS; break; case ERROR_WRITE_FAULT: case ERROR_READ_FAULT: case ERROR_GEN_FAILURE: errno = EIO; break; case ERROR_BUFFER_OVERFLOW: case ERROR_FILENAME_EXCED_RANGE: errno = ENAMETOOLONG; break; case ERROR_DELETE_PENDING: /* XXX map to EACCESS or EPERM? */ errno = EPERM; break; default: errno = EINVAL; break; } return -1; } #else int result = orig_stat (name, buf); if (result == 0) { # if REPLACE_FUNC_STAT_FILE /* Solaris 9 mistakenly succeeds when given a non-directory with a trailing slash. */ if (!S_ISDIR (buf->st_mode)) { size_t len = strlen (name); if (ISSLASH (name[len - 1])) { errno = ENOTDIR; return -1; } } # endif /* REPLACE_FUNC_STAT_FILE */ result = stat_time_normalize (result, buf); } return result; #endif }
//this will take a list of properties and convert it to internal values bool CBaseFXProps::ParseProperties(FX_PROP* pProps, uint32 nNumProps) { //counts of how many of each key uint32 nNumColorKeys = 0; uint32 nNumScaleKeys = 0; //go through the property list and parse in all the known variables and //count up how many of each key type we have uint32 nCurrProp = 0; for(nCurrProp = 0; nCurrProp < nNumProps; nCurrProp++) { FX_PROP& fxProp = pProps[nCurrProp]; if( !_stricmp( fxProp.m_sName, FXPROP_UPDATEPOS )) { m_nFollowType = (uint32)fxProp.GetComboVal(); } else if( !_stricmp( fxProp.m_sName, FXPROP_ATTACHNAME )) { fxProp.GetStringVal( m_szAttach ); } else if( !_stricmp( fxProp.m_sName, FXPROP_OFFSET )) { m_vOffset = fxProp.GetVector(); } else if( !_stricmp( fxProp.m_sName, FXPROP_ROTATEADD )) { m_vRotAdd = fxProp.GetVector(); } else if( !_stricmp( fxProp.m_sName, FXPROP_MENULAYER )) { m_nMenuLayer = fxProp.GetIntegerVal(); } else if( !_stricmp( fxProp.m_sName, "Ck" )) { nNumColorKeys++; } else if( !_stricmp( fxProp.m_sName, "Sk" )) { nNumScaleKeys++; } } //allocate our arrays of key types debug_deletea( m_pColorKeys ); m_pColorKeys = debug_newa( FX_COLOURKEY, nNumColorKeys ); m_nNumColorKeys = 0; debug_deletea( m_pScaleKeys ); m_pScaleKeys = debug_newa( FX_SCALEKEY, nNumScaleKeys ); m_nNumScaleKeys = 0; //now actually read in each key type for(nCurrProp = 0; nCurrProp < nNumProps; nCurrProp++) { FX_PROP& fxProp = pProps[nCurrProp]; if( !_stricmp( fxProp.m_sName, "Ck" )) { // Add this key to the list of keys FX_COLOURKEY fxClrKey; fxClrKey.m_tmKey = fxProp.m_data.m_clrKey.m_tmKey; fxClrKey.m_red = (float) (fxProp.m_data.m_clrKey.m_dwCol & 0x000000FF); fxClrKey.m_green = (float)((fxProp.m_data.m_clrKey.m_dwCol & 0x0000FF00) >> 8); fxClrKey.m_blue = (float)((fxProp.m_data.m_clrKey.m_dwCol & 0x00FF0000) >> 16); fxClrKey.m_alpha = (float)((fxProp.m_data.m_clrKey.m_dwCol & 0xFF000000) >> 24); if(m_pColorKeys) m_pColorKeys[m_nNumColorKeys++] = fxClrKey; } else if( !_stricmp( fxProp.m_sName, "Sk" ))
// The main programme int main( int argc, char *argv[] ) { printf( "%s\n", XBNBT_VER.c_str( ) ); #ifdef WIN32 if( argv[0] ) { char *szEndPos = strrchr( argv[0], CHAR_BS ); if( szEndPos ) { char *szEXEPath = new char[szEndPos - argv[0] + 1]; memcpy( szEXEPath, argv[0], szEndPos - argv[0] ); szEXEPath[szEndPos - argv[0]] = TERM_CHAR; SetCurrentDirectory( szEXEPath ); delete [] szEXEPath; } } if( argc > 1 ) { // The Trinity Edition 7.5r3 - Addition Begins // Added for Custom NT Service Name Code CFG_Open( CFG_FILE ); #define BNBT_SERVICE_NAME const_cast<LPSTR> (CFG_GetString( "cbtt_service_name", "BNBT Service" ).c_str()) CFG_Close( CFG_FILE ); printf( "Service name %s\n", string( BNBT_SERVICE_NAME ).c_str( ) ); // install service if( _stricmp( argv[1], "-i" ) == 0 ) { if( UTIL_NTServiceTest( ) ) printf( "BNBT Service is already installed!\n" ); else { if( UTIL_NTServiceInstall( ) ) printf( "BNBT Service installed.\n" ); else printf( "BNBT Service failed to install (error %d).\n", GetLastError( ) ); } return 0; } // uninstall service else if( _stricmp( argv[1], "-u" ) == 0 ) { if( !UTIL_NTServiceTest( ) ) printf( "BNBT Service is not installed!\n" ); else { if( UTIL_NTServiceUninstall( ) ) printf( "BNBT Service uninstalled.\n" ); else printf( "BNBT Service failed to uninstall (error %d).\n", GetLastError( ) ); } return 0; } // start else if( _stricmp( argv[1], "-start" ) == 0 ) { if( !UTIL_NTServiceTest( ) ) printf( "BNBT Service is not installed!\n" ); else { printf( "Starting BNBT Service.\n" ); if( !UTIL_NTServiceStart( ) ) printf( "BNBT Service failed to start (error %d).\n", GetLastError( ) ); } return 0; } // stop else if( _stricmp( argv[1], "-stop" ) == 0 ) { if( !UTIL_NTServiceTest( ) ) printf( "BNBT Service is not installed!\n" ); else { printf( "Stopping BNBT Service.\n" ); if( !UTIL_NTServiceStop( ) ) printf( "BNBT Service failed to stop (error %d).\n", GetLastError( ) ); } return 0; } // internal start else if( _stricmp( argv[1], "-s" ) == 0 ) { SERVICE_TABLE_ENTRY st[] = { { BNBT_SERVICE_NAME, NTServiceMain }, { 0, 0 } }; StartServiceCtrlDispatcher( st ); return 0; } // Print version information else if( _stricmp( argv[1], "-v" ) == 0 ) { printf( "%s\n", XBNBT_VER.c_str( ) ); return 0; } // Print help else if( ( _stricmp( argv[1], "-h" ) || _stricmp( argv[1], "-?" ) ) == 0 ) { printf("usage: bnbt [-i] [-u] [-start] [-stop] [-s] [-v] [-?|-h]\n" ); printf("Options:\n" ); printf("-?, -h : This help\n" ); printf("-i : Install NT Service\n" ); printf("-u : Unstall NT Service\n" ); printf("-start : Start NT Service\n" ); printf("-stop : Stop NT Service\n" ); printf("-s : Internal start NT Service\n" ); printf("-v : Show version\n" ); return 0; } } #else // read command-line arguments //char *example = 0; for ( int arg = 0; arg < argc; arg++ ) { if ( strcmp( argv[arg], "-v" ) == 0 || strcmp( argv[arg], "-version" ) == 0 ) { printf( "%s\n", XBNBT_VER.c_str( ) ); return 0; } //if (0 == strcmp(argv[arg], "-example")) { // if (arg+1 < argc) example = argv[arg+1]; //} if ( strcmp( argv[arg], "-help" ) == 0 || strcmp( argv[arg], "-?" ) == 0 || strcmp( argv[arg], "-h" ) == 0 ) { fprintf( stderr, "usage: %s [-v|-version] [-?|-h|-help]\n", argv[0] ); return 0; } } #endif printf( "Setting signals ... " ); #if defined ( SIGPIPE ) // disable SIGPIPE since some systems like OS X don't define MSG_NOSIGNAL signal( SIGPIPE, SIG_IGN ); #endif // catch SIGABRT, SIGINT, SIGTERM and SIGHUP signal( SIGABRT, sigCatcher ); signal( SIGINT, sigCatcher ); signal( SIGTERM, sigCatcher ); #if defined ( SIGHUP ) signal( SIGHUP, sigCatcher ); #endif printf( "Done\n" ); return bnbtmain( ); }
// This is the plugin messaging routine (i.e. V-REP calls this function very often, with various messages): VREP_DLLEXPORT void* v_repMessage(int message,int* auxiliaryData,void* customData,int* replyData) { // This is called quite often. Just watch out for messages/events you want to handle // Keep following 6 lines at the beginning and unchanged: simLockInterface(1); static bool refreshDlgFlag=true; int errorModeSaved; simGetIntegerParameter(sim_intparam_error_report_mode,&errorModeSaved); simSetIntegerParameter(sim_intparam_error_report_mode,sim_api_errormessage_ignore); void* retVal=NULL; // Here we can intercept many messages from V-REP (actually callbacks). Only the most important messages are listed here. // For a complete list of messages that you can intercept/react with, search for "sim_message_eventcallback"-type constants // in the V-REP user manual. if (message==sim_message_eventcallback_refreshdialogs) refreshDlgFlag=true; // V-REP dialogs were refreshed. Maybe a good idea to refresh this plugin's dialog too if (message==sim_message_eventcallback_menuitemselected) { // A custom menu bar entry was selected.. // here you could make a plugin's main dialog visible/invisible } if (message==sim_message_eventcallback_instancepass) { // This message is sent each time the scene was rendered (well, shortly after) (very often) // It is important to always correctly react to events in V-REP. This message is the most convenient way to do so: int flags=auxiliaryData[0]; bool sceneContentChanged=((flags&(1+2+4+8+16+32+64+256))!=0); // object erased, created, model or scene loaded, und/redo called, instance switched, or object scaled since last sim_message_eventcallback_instancepass message bool instanceSwitched=((flags&64)!=0); if (instanceSwitched) { // React to an instance switch here!! } if (sceneContentChanged) { // we actualize plugin objects for changes in the scene //... refreshDlgFlag=true; // always a good idea to trigger a refresh of this plugin's dialog here } } if (message==sim_message_eventcallback_mainscriptabouttobecalled) { // The main script is about to be run (only called while a simulation is running (and not paused!)) } if (message==sim_message_eventcallback_simulationabouttostart) { // Simulation is about to start } if (message==sim_message_eventcallback_simulationended) { // Simulation just ended } if (message==sim_message_eventcallback_moduleopen) { // A script called simOpenModule (by default the main script). Is only called during simulation. if ( (customData==NULL)||(_stricmp("PluginSkeleton",(char*)customData)==0) ) // is the command also meant for this plugin? { // we arrive here only at the beginning of a simulation } } if (message==sim_message_eventcallback_modulehandle) { // A script called simHandleModule (by default the main script). Is only called during simulation. if ( (customData==NULL)||(_stricmp("PluginSkeleton",(char*)customData)==0) ) // is the command also meant for this plugin? { // we arrive here only while a simulation is running } } if (message==sim_message_eventcallback_moduleclose) { // A script called simCloseModule (by default the main script). Is only called during simulation. if ( (customData==NULL)||(_stricmp("PluginSkeleton",(char*)customData)==0) ) // is the command also meant for this plugin? { // we arrive here only at the end of a simulation } } if (message==sim_message_eventcallback_instanceswitch) { // Here the user switched the scene. React to this message in a similar way as you would react to a full // scene content change. In this plugin example, we react to an instance switch by reacting to the // sim_message_eventcallback_instancepass message and checking the bit 6 (64) of the auxiliaryData[0] // (see here above) } if (message==sim_message_eventcallback_broadcast) { // Here we have a plugin that is broadcasting data (the broadcaster will also receive this data!) } if (message==sim_message_eventcallback_scenesave) { // The scene is about to be saved. If required do some processing here (e.g. add custom scene data to be serialized with the scene) } // You can add many more messages to handle here if ((message==sim_message_eventcallback_guipass)&&refreshDlgFlag) { // handle refresh of the plugin's dialogs // ... refreshDlgFlag=false; } // Keep following unchanged: simSetIntegerParameter(sim_intparam_error_report_mode,errorModeSaved); // restore previous settings simLockInterface(0); return(retVal); }
/* Internal: Find the LCID for a locale specification */ static LCID MSVCRT_locale_to_LCID(locale_search_t* locale) { LCID lcid; EnumResourceLanguagesA(GetModuleHandleA("KERNEL32"), (LPSTR)RT_STRING, (LPCSTR)LOCALE_ILANGUAGE,find_best_locale_proc, (LONG_PTR)locale); if (!locale->match_flags) return 0; /* If we were given something that didn't match, fail */ if (locale->search_country[0] && !(locale->match_flags & FOUND_COUNTRY)) return 0; lcid = MAKELCID(locale->found_lang_id, SORT_DEFAULT); /* Populate partial locale, translating LCID to locale string elements */ if (!locale->found_codepage[0]) { /* Even if a codepage is not enumerated for a locale * it can be set if valid */ if (locale->search_codepage[0]) { if (IsValidCodePage(atoi(locale->search_codepage))) memcpy(locale->found_codepage,locale->search_codepage,MAX_ELEM_LEN); else { /* Special codepage values: OEM & ANSI */ if (_stricmp(locale->search_codepage,"OCP")) { GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE, locale->found_codepage, MAX_ELEM_LEN); } if (_stricmp(locale->search_codepage,"ACP")) { GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE, locale->found_codepage, MAX_ELEM_LEN); } else return 0; if (!atoi(locale->found_codepage)) return 0; } } else { /* Prefer ANSI codepages if present */ GetLocaleInfoA(lcid, LOCALE_IDEFAULTANSICODEPAGE, locale->found_codepage, MAX_ELEM_LEN); if (!locale->found_codepage[0] || !atoi(locale->found_codepage)) GetLocaleInfoA(lcid, LOCALE_IDEFAULTCODEPAGE, locale->found_codepage, MAX_ELEM_LEN); } } GetLocaleInfoA(lcid, LOCALE_SENGLANGUAGE|LOCALE_NOUSEROVERRIDE, locale->found_language, MAX_ELEM_LEN); GetLocaleInfoA(lcid, LOCALE_SENGCOUNTRY|LOCALE_NOUSEROVERRIDE, locale->found_country, MAX_ELEM_LEN); return lcid; }
KUSB_HANDLE USBDevice::FindDevice() { KLST_HANDLE DeviceList = NULL; KUSB_HANDLE handle = NULL; KLST_DEVINFO_HANDLE DeviceInfo = NULL; KLST_DEVINFO_HANDLE tmpDeviceInfo = NULL; ULONG deviceCount = 0; m_errorCode = ERROR_SUCCESS; // Get the device list if (!LstK_Init(&DeviceList, KLST_FLAG_NONE)) { #ifdef _DEBUG debugPrintf("ASIOUAC: Error initializing device list.\n"); #endif return NULL; } LstK_Count(DeviceList, &deviceCount); if (!deviceCount) { #ifdef _DEBUG debugPrintf("ASIOUAC: No devices in device list.\n"); #endif SetLastError(ERROR_DEVICE_NOT_CONNECTED); // If LstK_Init returns TRUE, the list must be freed. LstK_Free(DeviceList); return NULL; } #ifdef _DEBUG debugPrintf("ASIOUAC: Looking for device with DeviceInterfaceGUID %s\n", _T(_DeviceInterfaceGUID)); #endif LstK_MoveReset(DeviceList); // // // Call LstK_MoveNext after a LstK_MoveReset to advance to the first // element. while(LstK_MoveNext(DeviceList, &tmpDeviceInfo) && DeviceInfo == NULL) { if(!_stricmp(tmpDeviceInfo->DeviceInterfaceGUID, _DeviceInterfaceGUID) && tmpDeviceInfo->Connected) { DeviceInfo = tmpDeviceInfo; break; } } if (!DeviceInfo) { #ifdef _DEBUG debugPrintf("ASIOUAC: Device not found.\n"); #endif // If LstK_Init returns TRUE, the list must be freed. LstK_Free(DeviceList); return NULL; } // Initialize the device with the "dynamic" Open function if (!UsbK_Init(&handle, DeviceInfo)) { handle = NULL; m_errorCode = GetLastError(); #ifdef _DEBUG debugPrintf("ASIOUAC: UsbK_Init failed. ErrorCode: %08Xh\n", m_errorCode); #endif } LstK_Free(DeviceList); return handle; }
int __cdecl strcasecmp(_In_z_ const char * s1, _In_z_ const char * s2) { return _stricmp(s1, s2); }
int wmain(int argc, wchar_t **wcargv) { char** argv; #else int main(int argc, char** argv) { #endif int eargv_size; int eargc_base; /* How many arguments in the base of eargv. */ char* emulator; char* basename; char* def_emu_lookup_path; char scriptname[PMAX]; char** last_opt; char** first_opt; #ifdef __WIN32__ int i; int len; /* Convert argv to utf8 */ argv = emalloc((argc+1) * sizeof(char*)); for (i=0; i<argc; i++) { len = WideCharToMultiByte(CP_UTF8, 0, wcargv[i], -1, NULL, 0, NULL, NULL); argv[i] = emalloc(len*sizeof(char)); WideCharToMultiByte(CP_UTF8, 0, wcargv[i], -1, argv[i], len, NULL, NULL); } argv[argc] = NULL; #endif /* * Allocate the argv vector to be used for arguments to Erlang. * Arrange for starting to pushing information in the middle of * the array, to allow easy addition of commands in the beginning. */ eargv_size = argc*4+1000+LINEBUFSZ/2; eargv_base = (char **) emalloc(eargv_size*sizeof(char*)); eargv = eargv_base; eargc = 0; eargc_base = eargc; eargv = eargv + eargv_size/2; eargc = 0; /* Determine basename of the executable */ for (basename = argv[0]+strlen(argv[0]); basename > argv[0] && !(IS_DIRSEP(basename[-1])); --basename) ; first_opt = argv; last_opt = argv; #ifdef __WIN32__ if ( (_stricmp(basename, "escript.exe") == 0) ||(_stricmp(basename, "escript") == 0)) { #else if (strcmp(basename, "escript") == 0) { #endif def_emu_lookup_path = argv[0]; /* * Locate all options before the script name. */ while (argc > 1 && argv[1][0] == '-') { argc--; argv++; last_opt = argv; } if (argc <= 1) { error("Missing filename\n"); } strncpy(scriptname, argv[1], sizeof(scriptname)); scriptname[sizeof(scriptname)-1] = '\0'; argc--; argv++; } else { char *absname = find_prog(argv[0]); #ifdef __WIN32__ int len = strlen(absname); if (len >= 4 && _stricmp(absname+len-4, ".exe") == 0) { absname[len-4] = '\0'; } #endif erts_snprintf(scriptname, sizeof(scriptname), "%s.escript", absname); efree(absname); def_emu_lookup_path = scriptname; } /* Determine path to emulator */ emulator = get_env("ESCRIPT_EMULATOR"); if (emulator == NULL) { emulator = get_default_emulator(def_emu_lookup_path); } if (strlen(emulator) >= PMAX) error("Value of environment variable ESCRIPT_EMULATOR is too large"); /* * Push initial arguments. */ PUSH(emulator); PUSH("+B"); PUSH2("-boot", "no_dot_erlang"); PUSH("-noshell"); /* * Read options from the %%! row in the script and add them as args */ append_shebang_args(scriptname); /* * Push the script name and everything following it as extra arguments. */ PUSH3("-run", "escript", "start"); /* * Push all options before the script name. But omit the leading hyphens. */ while (first_opt != last_opt) { PUSH(first_opt[1]+1); first_opt++; } PUSH("-extra"); PUSH(scriptname); while (argc > 1) { PUSH(argv[1]); argc--, argv++; } /* * Move up the commands for invoking the emulator and adjust eargv * accordingly. */ while (--eargc_base >= 0) { UNSHIFT(eargv_base[eargc_base]); } /* * Add scriptname to env */ set_env("ESCRIPT_NAME", scriptname); /* * Invoke Erlang with the collected options. */ PUSH(NULL); return run_erlang(eargv[0], eargv); } #ifdef __WIN32__ wchar_t *make_commandline(char **argv) { static wchar_t *buff = NULL; static int siz = 0; int num = 0, len; char **arg; wchar_t *p; if (*argv == NULL) { return L""; } for (arg = argv; *arg != NULL; ++arg) { num += strlen(*arg)+1; } if (!siz) { siz = num; buff = (wchar_t *) emalloc(siz*sizeof(wchar_t)); } else if (siz < num) { siz = num; buff = (wchar_t *) erealloc(buff,siz*sizeof(wchar_t)); } p = buff; num=0; for (arg = argv; *arg != NULL; ++arg) { len = MultiByteToWideChar(CP_UTF8, 0, *arg, -1, p, siz); p+=(len-1); *p++=L' '; } *(--p) = L'\0'; if (debug) { printf("Processed command line:%S\n",buff); } return buff; } int my_spawnvp(char **argv) { STARTUPINFOW siStartInfo; PROCESS_INFORMATION piProcInfo; DWORD ec; memset(&siStartInfo,0,sizeof(STARTUPINFOW)); siStartInfo.cb = sizeof(STARTUPINFOW); siStartInfo.dwFlags = STARTF_USESTDHANDLES; siStartInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE); siStartInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); siStartInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE); if (!CreateProcessW(NULL, make_commandline(argv), NULL, NULL, TRUE, 0, NULL, NULL, &siStartInfo, &piProcInfo)) { return -1; } CloseHandle(piProcInfo.hThread); WaitForSingleObject(piProcInfo.hProcess,INFINITE); if (!GetExitCodeProcess(piProcInfo.hProcess,&ec)) { return 0; } return (int) ec; }
DWORD GetExplorerLogonPid() { DWORD dwSessionId; DWORD dwExplorerLogonPid=0; PROCESSENTRY32 procEntry; // HANDLE hProcess,hPToken; pWTSGetActiveConsoleSessionId WTSGetActiveConsoleSessionIdF=NULL; WTSProcessIdToSessionIdF=NULL; HMODULE hlibkernel = LoadLibrary("kernel32.dll"); if (hlibkernel) { WTSGetActiveConsoleSessionIdF=(pWTSGetActiveConsoleSessionId)GetProcAddress(hlibkernel, "WTSGetActiveConsoleSessionId"); WTSProcessIdToSessionIdF=(pProcessIdToSessionId)GetProcAddress(hlibkernel, "ProcessIdToSessionId"); } if (WTSGetActiveConsoleSessionIdF!=NULL) dwSessionId =WTSGetActiveConsoleSessionIdF(); else dwSessionId=0; if( GetSystemMetrics( SM_REMOTESESSION)) if (WTSProcessIdToSessionIdF!=NULL) { DWORD dw = GetCurrentProcessId(); DWORD pSessionId = 0xFFFFFFFF; WTSProcessIdToSessionIdF( dw, &pSessionId ); dwSessionId=pSessionId; } HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hSnap == INVALID_HANDLE_VALUE) { if (hlibkernel) FreeLibrary(hlibkernel); return 0 ; } procEntry.dwSize = sizeof(PROCESSENTRY32); if (!Process32First(hSnap, &procEntry)) { CloseHandle(hSnap); if (hlibkernel) FreeLibrary(hlibkernel); return 0 ; } do { if (_stricmp(procEntry.szExeFile, "explorer.exe") == 0) { DWORD dwExplorerSessId = 0; if (WTSProcessIdToSessionIdF!=NULL) { if (WTSProcessIdToSessionIdF(procEntry.th32ProcessID, &dwExplorerSessId) && dwExplorerSessId == dwSessionId) { dwExplorerLogonPid = procEntry.th32ProcessID; break; } } else dwExplorerLogonPid = procEntry.th32ProcessID; } } while (Process32Next(hSnap, &procEntry)); CloseHandle(hSnap); if (hlibkernel) FreeLibrary(hlibkernel); return dwExplorerLogonPid; }
int Platform::Stricmp(const char *str1, const char *str2) { return _stricmp(str1, str2); }
/************************************************************************************************** This function handles events. **************************************************************************************************/ void CGroup::HandleEvent(UINT uEvent) { if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_NONE) == 0) { return; } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_RENAME) == 0) { ListView_EditLabel(m_hwndListView, ListView_GetNextItem(m_hwndListView, -1, LVNI_FOCUSED)); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_EXECUTE) == 0) { if (ListView_GetSelectedCount(m_hwndListView) == 1) { int iItem = ListView_GetNextItem(m_hwndListView, -1, LVNI_SELECTED); char szFileName[MAX_PATH]; if (GetNameFromId(iItem, szFileName, sizeof(szFileName))) { if (utils::Is_Directory(szFileName)) { if (m_bInlineBrowsing) { return ChangeDir(".selected"); } else if (m_bExplicitCalls) { LSExecuteEx(NULL, "open", "explorer.exe", szFileName, NULL, SW_SHOWNORMAL); return; } } } } CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_RETURN, NULL); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_DELETE) == 0) { DeleteFiles(); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_PASTE) == 0) { DoPaste(); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UNDO) == 0) { // TODO::Add support for this } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_COPY) == 0) { CopyFiles(false); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_CUT) == 0) { CopyFiles(true); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_SELECTALL) == 0) { ListView_SetItemState(m_hwndListView, -1, LVIS_SELECTED, LVIS_SELECTED); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_REFRESH) == 0) { SaveState(); m_pView2->Refresh(); RestoreState(); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UP) == 0) { ChangeDir(".up"); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_CHANGEDIR) == 0) { ChangeDir(".selected"); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_DOWNKEY) == 0) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_DOWN, NULL); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_UPKEY) == 0) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_UP, NULL); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_LEFTKEY) == 0) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_LEFT, NULL); } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_RIGHTKEY) == 0) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_KEYDOWN, VK_RIGHT, NULL); } else { LSExecute(m_hwndListView, m_szEventCommand[uEvent], SW_SHOWNORMAL); } }
/************************************************************************************************** This function handles mouse events. **************************************************************************************************/ void CGroup::HandleMouseEvent(UINT uEvent, UINT msg, WPARAM wParam, LPARAM lParam) { if (m_bExplorerDesktop) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, msg, wParam, lParam); return; } if (msg == WM_LBUTTONDOWN || msg == WM_RBUTTONDOWN || msg == WM_LBUTTONDBLCLK) { LVHITTESTINFO lvhi = {0}; lvhi.flags = LVHT_ONITEM; lvhi.pt.x = GET_X_LPARAM(lParam); lvhi.pt.y = GET_Y_LPARAM(lParam); if ( ListView_HitTest(m_hwndListView, &lvhi) != -1 ) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, msg, wParam, lParam); if (msg == WM_LBUTTONDOWN && m_bSingleClick) SendMessage(m_hwndListView, WM_LBUTTONDBLCLK, wParam, lParam); return; // An icon was clicked. } } if (m_bStealFocus) SetFocus(m_hwndListView); if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_CHANGEDIR) == 0) { // We can override HandleEvent actions like this ;) LVHITTESTINFO lvhi = {0}; lvhi.flags = LVHT_ONITEM; lvhi.pt.x = GET_X_LPARAM(lParam); lvhi.pt.y = GET_Y_LPARAM(lParam); if (msg == WM_MOUSEWHEEL || msg == WM_MOUSEHWHEEL) { MapWindowPoints(HWND_DESKTOP, m_hwndListView, &lvhi.pt, 1); } int nFileid = ListView_HitTest(m_hwndListView, &lvhi); if ( nFileid != -1 ) { char szFileName[MAX_PATH]; if (GetNameFromId(nFileid, szFileName, sizeof(szFileName))) { if (utils::Is_Directory(szFileName)) { if (!m_bNoVirtualSwitch && (_stricmp(szFileName, m_szDesktopPath) == 0)) { ChangeDir(".desktop"); } else { ChangeDir(szFileName); } return; } } } } // We just need to handle the mouse specific events and then forward the event to HandleEvent if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_RECTANGLE) == 0) { if (CheckModkeys(m_wSelectionRectangleMod)) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_LBUTTONDOWN, wParam, lParam); } else { relayMouseMessage(msg, wParam, lParam); } } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_SYSTEMMENU) == 0) { if (CheckModkeys(m_wSystemMenuMod)) { CallWindowProc(m_wpOrigListViewProc, m_hwndListView, WM_RBUTTONDOWN, wParam, lParam); } else { relayMouseMessage(msg, wParam, lParam); } } else if (_stricmp(m_szEventCommand[uEvent], EVENT_ACTION_FORWARD) == 0) { relayMouseMessage(msg, wParam, lParam); } else { HandleEvent(uEvent); } }
RNS2BindResult RNS2_Berkley::BindSharedIPV4And6( RNS2_BerkleyBindParameters *bindParameters, const char *file, unsigned int line ) { (void) file; (void) line; (void) bindParameters; #if RAKNET_SUPPORT_IPV6==1 int ret=0; struct addrinfo hints; struct addrinfo *servinfo=0, *aip; // will point to the results PrepareAddrInfoHints2(&hints); hints.ai_family=bindParameters->addressFamily; char portStr[32]; Itoa(bindParameters->port,portStr,10); // On Ubuntu, "" returns "No address associated with hostname" while 0 works. if (bindParameters->hostAddress && (_stricmp(bindParameters->hostAddress,"UNASSIGNED_SYSTEM_ADDRESS")==0 || bindParameters->hostAddress[0]==0)) { getaddrinfo(0, portStr, &hints, &servinfo); } else { getaddrinfo(bindParameters->hostAddress, portStr, &hints, &servinfo); } // Try all returned addresses until one works for (aip = servinfo; aip != NULL; aip = aip->ai_next) { // Open socket. The address type depends on what // getaddrinfo() gave us. rns2Socket = socket__(aip->ai_family, aip->ai_socktype, aip->ai_protocol); if (rns2Socket == -1) return BR_FAILED_TO_BIND_SOCKET; ret = bind__(rns2Socket, aip->ai_addr, (int) aip->ai_addrlen ); if (ret>=0) { // Is this valid? memcpy(&boundAddress.address.addr6, aip->ai_addr, sizeof(boundAddress.address.addr6)); freeaddrinfo(servinfo); // free the linked-list SetSocketOptions(); SetNonBlockingSocket(bindParameters->nonBlockingSocket); SetBroadcastSocket(bindParameters->setBroadcast); GetSystemAddressIPV4And6( rns2Socket, &boundAddress ); return BR_SUCCESS; } else { closesocket__(rns2Socket); } } return BR_FAILED_TO_BIND_SOCKET; #else return BR_REQUIRES_RAKNET_SUPPORT_IPV6_DEFINE; #endif }
// Packet when user login (chck user and pass and active) bool CLoginServer::pakUserLogin( CLoginClient* thisclient, CPacket* P ) { if ( thisclient->isLoggedIn ) return false; MYSQL_ROW row; string temp_string; string temp_password; temp_string.reserve(17); temp_password.reserve(33); temp_string.assign( (const char*)&P->Buffer, 32, (P->Size-6-32)>16?16:P->Size-6-32 ); temp_password.assign((const char*)&P->Buffer, 0, 32 ); EscapeMySQL(temp_password.c_str(),thisclient->password,-1,true); //client sends already in MD5 form (or should...) if (!thisclient->hasGameGuard && Config.checkGameGuard ) { Log(MSG_HACK, "Warning, user [ %s ] tried logging in without gameguard", temp_string.c_str()); BEGINPACKET( pak, 0x708 ); ADDBYTE( pak, 10 ); ADDDWORD( pak, 0); thisclient->SendPacket( &pak ); return false; } BEGINPACKET( pak, 0x708 ); if(!EscapeMySQL(temp_string.c_str(),thisclient->username,16,true)) { return false; } MYSQL_RES *result = DB->QStore( "SELECT id,password,accesslevel,online,active FROM accounts WHERE username='******'", thisclient->username.c_str() ); if(result == NULL) return false; if( mysql_num_rows( result ) == 1 ) { row = mysql_fetch_row(result); int res = 0; #ifdef _WIN32 res = _stricmp( row[1], thisclient->password.c_str() ); #else res = strcasecmp( row[1], thisclient->password.c_str() ); #endif if ( res == 0 ) { //Account is Active if(atoi(row[4])==1) { // Activation Fix By Rifke Log( MSG_INFO, "Success login '%s' : Account verfified.", thisclient->username.c_str() ); // characters is already logged if(atoi(row[3])==1) { Log(MSG_WARNING, "Account %s try re-login", thisclient->username.c_str() ); ADDBYTE( pak, 4 ); ADDDWORD( pak, 0 ); thisclient->SendPacket( &pak ); //relogin crash fixed by zrose. BEGINPACKET( pak2, 0x502 ); ADDBYTE ( pak2, 1 ); ADDDWORD ( pak2, atoi(row[0]) ); cryptPacket( (char*)&pak2, NULL ); DB->QFree( ); for(UINT i=0;i<ServerList.size();i++) send( ServerList.at(i)->sock , (char*)&pak2, pak2.Size, 0 ); DB->QExecute( "update accounts set online=0 WHERE username='******'", thisclient->username.c_str()); return false; } thisclient->accesslevel = atoi(row[2]); //LMA: banned handled after this check. if( thisclient->accesslevel >0 && thisclient->accesslevel < Config.MinimumAccessLevel ) { //The server are under inspection ADDBYTE( pak, 0 ); ADDDWORD( pak, 0 ); thisclient->SendPacket( &pak ); DB->QFree( ); return true; } if ( thisclient->accesslevel > 0 ) { thisclient->userid = atoi(row[0]); thisclient->isLoggedIn = true; DB->QFree( ); //new code. ADDBYTE( pak, 0x80 ); if(thisclient->accesslevel==300) { //GM level 1 ADDWORD( pak, 256 ); } else if(thisclient->accesslevel==400) { //GM level 2 ADDWORD( pak, 512 ); } else if(thisclient->accesslevel==500) { //admin. ADDWORD( pak, 768 ); } else { //standard user. ADDWORD( pak, 100 ); } ADDWORD( pak, 0x0000); result = DB->QStore( "SELECT id,name FROM channels WHERE type=1" ); if(result==NULL) return false; while( row = mysql_fetch_row(result) ) { ADDBYTE( pak, 30 + atoi(row[0])); ADDSTRING( pak, row[1] ); ADDBYTE( pak, 0 ); ADDBYTE(pak, atoi( row[0] ) ); ADDBYTE( pak, 0 ); ADDWORD( pak, 0 ); } DB->QFree( ); }else{ //BANNED ADDBYTE( pak, 5 ); ADDDWORD( pak, 0 ); DB->QFree( ); } }else{ // Not activated Log( MSG_INFO, "Account %s not verified ", thisclient->username.c_str() ); ADDBYTE( pak, 9 ); ADDDWORD( pak, 0 ); DB->QFree( ); } }else{ //BAD PASSWORD ADDBYTE( pak, 3 ); ADDDWORD( pak, 0 ); DB->QFree( ); } } else { //BAD USERNAME ADDBYTE( pak, 2 ); ADDDWORD( pak, 0 ); DB->QFree( ); } /* 1 - general error | 4 - your account is already logged 6 - topup account | 7 - cannot connect to server please try again 8 - server exceeded | 9 - account have not been verified 10 - login failed | 11 - ip capacity is full */ thisclient->SendPacket ( &pak ); return true; }
/* TAccount: Account Management */ bool TAccount::meetsConditions( CString fileName, CString conditions ) { const char* conditional[] = { ">=", "<=", "!=", "=", ">", "<" }; // Load and check if the file is valid. std::vector<CString> file; file = CString::loadToken(fileName, "\n", true); if (file.size() == 0 || (file.size() != 0 && file[0] != "GRACC001")) return false; // Load the conditions into a string list. std::vector<CString> cond; conditions.removeAllI("'"); conditions.replaceAllI("%", "*"); cond = conditions.tokenize(","); bool* conditionsMet = new bool[cond.size()]; memset((void*)conditionsMet, 0, sizeof(bool) * cond.size()); // Go through each line of the loaded file. for (std::vector<CString>::iterator i = file.begin(); i != file.end(); ++i) { int sep = (*i).find(' '); CString section = (*i).subString(0, sep); CString val = (*i).subString(sep + 1).removeAll("\r"); section.trimI(); val.trimI(); // Check each line against the conditions specified. for (unsigned int j = 0; j < cond.size(); ++j) { int cond_num = -1; // Read out the name and value. cond[j].setRead(0); // Find out what conditional we are using. for (int k = 0; k < 6; ++k) { if (cond[j].find(conditional[k]) != -1) { cond_num = k; k = 6; } } if (cond_num == -1) continue; CString cname = cond[j].readString(conditional[cond_num]); CString cvalue = cond[j].readString(""); cname.trimI(); cvalue.trimI(); cond[j].setRead(0); // Now, do a case-insensitive comparison of the section name. #ifdef WIN32 if (_stricmp(section.text(), cname.text()) == 0) #else if (strcasecmp(section.text(), cname.text()) == 0) #endif { switch (cond_num) { case 0: case 1: { // 0: >= // 1: <= // Check if it is a number. If so, do a number comparison. bool condmet = false; if (val.isNumber()) { double vNum[2] = { atof(val.text()), atof(cvalue.text()) }; if (((cond_num == 1) ? (vNum[0] <= vNum[1]) : (vNum[0] >= vNum[1]))) { conditionsMet[j] = true; condmet = true; } } else { // If not a number, do a string comparison. int ret = strcmp(val.text(), cvalue.text()); if (((cond_num == 1) ? (ret <= 0) : (ret >= 0))) { conditionsMet[j] = true; condmet = true; } } // No conditions met means we see if we can fail. if (condmet == false) { CString cnameUp = cname.toUpper(); if (!(cnameUp == "CHEST" || cnameUp == "WEAPON" || cnameUp == "FLAG" || cnameUp == "FOLDERRIGHT")) goto condAbort; } break; } case 4: case 5: { // 4: > // 5: < bool condmet = false; if (val.isNumber()) { double vNum[2] = { atof(val.text()), atof(cvalue.text()) }; if (((cond_num == 5) ? (vNum[0] < vNum[1]) : (vNum[0] > vNum[1]))) { conditionsMet[j] = true; condmet = true; } } else { int ret = strcmp(val.text(), cvalue.text()); if (((cond_num == 5) ? (ret < 0) : (ret > 0))) { conditionsMet[j] = true; condmet = true; } } if (condmet == false) { CString cnameUp = cname.toUpper(); if (!(cnameUp == "CHEST" || cnameUp == "WEAPON" || cnameUp == "FLAG" || cnameUp == "FOLDERRIGHT")) goto condAbort; } break; } case 2: { // 2: != // If we find a match, return false. if (val.isNumber()) { double vNum[2] = { atof(val.text()), atof(cvalue.text()) }; if (vNum[0] == vNum[1]) goto condAbort; conditionsMet[j] = true; } else { if (val.match(cvalue.text()) == true) goto condAbort; conditionsMet[j] = true; } break; } case 3: default: { // 0 - equals // If it returns false, don't include this account in the search. bool condmet = false; if (val.isNumber()) { double vNum[2] = { atof(val.text()), atof(cvalue.text()) }; if (vNum[0] == vNum[1]) { conditionsMet[j] = true; condmet = true; } } else { if (val.match(cvalue.text()) == true) { conditionsMet[j] = true; condmet = true; } } if (condmet == false) { CString cnameUp = cname.toUpper(); if (!(cnameUp == "CHEST" || cnameUp == "WEAPON" || cnameUp == "FLAG" || cnameUp == "FOLDERRIGHT")) goto condAbort; } break; } } } } } // Check if all the conditions were met. for (unsigned int i = 0; i < cond.size(); ++i) if (conditionsMet[i] == false) goto condAbort; // Clean up. delete [] conditionsMet; return true; condAbort: delete [] conditionsMet; return false; }
static int CompareLists(const MsnContact* p1, const MsnContact* p2) { return _stricmp(p1->email, p2->email); }
bool cbDebugSetJIT(int argc, char* argv[]) { arch actual_arch = invalid; char* jit_debugger_cmd = ""; Memory<char*> oldjit(MAX_SETTING_SIZE + 1); char path[JIT_ENTRY_DEF_SIZE]; if(!IsProcessElevated()) { dputs(QT_TRANSLATE_NOOP("DBG", "Error run the debugger as Admin to setjit\n")); return false; } if(argc < 2) { dbggetdefjit(path); jit_debugger_cmd = path; if(!dbgsetjit(jit_debugger_cmd, notfound, &actual_arch, NULL)) { dprintf(QT_TRANSLATE_NOOP("DBG", "Error setting JIT %s\n"), (actual_arch == x64) ? "x64" : "x32"); return false; } } else if(argc == 2) { if(!_strcmpi(argv[1], "old")) { jit_debugger_cmd = oldjit(); if(!BridgeSettingGet("JIT", "Old", jit_debugger_cmd)) { dputs(QT_TRANSLATE_NOOP("DBG", "Error there is no old JIT entry stored.")); return false; } if(!dbgsetjit(jit_debugger_cmd, notfound, &actual_arch, NULL)) { dprintf(QT_TRANSLATE_NOOP("DBG", "Error setting JIT %s\n"), (actual_arch == x64) ? "x64" : "x32"); return false; } } else if(!_strcmpi(argv[1], "oldsave")) { dbggetdefjit(path); char get_entry[JIT_ENTRY_MAX_SIZE] = ""; bool get_last_jit = true; if(!dbggetjit(get_entry, notfound, &actual_arch, NULL)) { get_last_jit = false; } else strcpy_s(oldjit(), MAX_SETTING_SIZE, get_entry); jit_debugger_cmd = path; if(!dbgsetjit(jit_debugger_cmd, notfound, &actual_arch, NULL)) { dprintf(QT_TRANSLATE_NOOP("DBG", "Error setting JIT %s\n"), (actual_arch == x64) ? "x64" : "x32"); return false; } if(get_last_jit) { if(_stricmp(oldjit(), path)) BridgeSettingSet("JIT", "Old", oldjit()); } } else if(!_strcmpi(argv[1], "restore")) { jit_debugger_cmd = oldjit(); if(!BridgeSettingGet("JIT", "Old", jit_debugger_cmd)) { dputs(QT_TRANSLATE_NOOP("DBG", "Error there is no old JIT entry stored.")); return false; } if(!dbgsetjit(jit_debugger_cmd, notfound, &actual_arch, NULL)) { dprintf(QT_TRANSLATE_NOOP("DBG", "Error setting JIT %s\n"), (actual_arch == x64) ? "x64" : "x32"); return false; } BridgeSettingSet("JIT", 0, 0); } else { jit_debugger_cmd = argv[1]; if(!dbgsetjit(jit_debugger_cmd, notfound, &actual_arch, NULL)) { dprintf(QT_TRANSLATE_NOOP("DBG", "Error setting JIT %s\n"), (actual_arch == x64) ? "x64" : "x32"); return false; } } } else if(argc == 3) { readwritejitkey_error_t rw_error; if(!_strcmpi(argv[1], "old")) { BridgeSettingSet("JIT", "Old", argv[2]); dprintf(QT_TRANSLATE_NOOP("DBG", "New OLD JIT stored: %s\n"), argv[2]); return true; } else if(_strcmpi(argv[1], "x64") == 0) actual_arch = x64; else if(_strcmpi(argv[1], "x32") == 0) actual_arch = x32; else { dputs(QT_TRANSLATE_NOOP("DBG", "Unknown JIT entry type. Use OLD, x64 or x32 as parameter.")); return false; } jit_debugger_cmd = argv[2]; if(!dbgsetjit(jit_debugger_cmd, actual_arch, NULL, &rw_error)) { if(rw_error == ERROR_RW_NOTWOW64) dputs(QT_TRANSLATE_NOOP("DBG", "Error using x64 arg. The debugger is not a WOW64 process\n")); else dprintf(QT_TRANSLATE_NOOP("DBG", "Error setting JIT %s\n"), (actual_arch == x64) ? "x64" : "x32"); return false; } } else { dputs(QT_TRANSLATE_NOOP("DBG", "Error unknown parameters. Use old, oldsave, restore, x86 or x64 as parameter.")); return false; } dprintf(QT_TRANSLATE_NOOP("DBG", "New JIT %s: %s\n"), (actual_arch == x64) ? "x64" : "x32", jit_debugger_cmd); return true; }
inline int strcasecmp(const char *c1, const char *c2){ return _stricmp(c1,c2); }
int CScriptEngine::Do_Compare(int OP,const char *szA, const char *szB,BOOL bCompareMode) { switch(OP) { case 1: //== { if((szA==NULL) || (szB==NULL)) return 0; if(bCompareMode) //substring compare? return wildcmp(szA, szB); //(strstr(szA,szB)!=NULL); //strstr substring compare else return ( strcmp(szA,szB)==0); } case 2: //!= NOT equal to { if((szA==NULL) || (szB==NULL)) return 1; if(bCompareMode) //substring compare? return (wildcmp(szA, szB)==0); //(strstr(szA,szB)==NULL); //NOT strstr else return (strcmp(szA,szB)!=0); //exact compare } case 3: //~== case insensitive compare { if((szA==NULL) || (szB==NULL)) return 0; if(bCompareMode) //substring compare return wildicmp(szA, szB); //(stristr((TCHAR*)szA,szB)!=NULL); //substring compare else return (_stricmp(szA,szB)==0); //exact compare } case 4: //~!= { if((szA==NULL) || (szB==NULL)) return 1; if(bCompareMode) //substring compare NOT return (wildicmp(szA, szB)==0); //(stristr((TCHAR*)szA,szB)==NULL); else return (_stricmp(szA,szB)!=0); //exact compare } case 5: { if((szA==NULL) || (szB==NULL)) return 0; return (atoi(szA)<atoi(szB)); } case 6: { if((szA==NULL) || (szB==NULL)) return 0; return (atoi(szA)<=atoi(szB)); } case 7: { if((szA==NULL) || (szB==NULL)) return 0; return (atoi(szA)>atoi(szB)); } case 8: { if((szA==NULL) || (szB==NULL)) return 0; return (atoi(szA)>=atoi(szB)); } } return 0; }
CAT_INLINE bool iStrEqual(const char *A, const char *B) { return _stricmp(A, B) == 0; }
//------------------------------------------------------------------ // Brings up a file chooser and then saves the painted image // This is called by the UI when the save image menu item is chosen //------------------------------------------------------------------ void ImpressionistUI::cb_save_image(Fl_Menu_* o, void* v) { ImpressionistDoc *pDoc=whoami(o)->getDocument(); /*pDoc->m_pUI->m_chooser = new Fl_File_Chooser(".", "*.png\t*.jpg", Fl_File_Chooser::CREATE, "Save"); pDoc->m_pUI->m_chooser->show(); while(pDoc->m_pUI->m_chooser->shown()) { Fl::wait(); }*/ const char* filename = pDoc->m_pUI->fileDialog( Fl_Native_File_Chooser::BROWSE_SAVE_FILE, "PNG Image File (*.png)\t*.png\nJPEG Image File (*.jpg)\t*.jpg"); if(filename) { std::string strFileName = (std::string)filename; std::string ext; int quality = 95; switch(pDoc->m_pUI->m_nativeChooser->filter_value()) { case 0: ext = ".png"; break; case 1: ext = ".jpg"; break; } #ifdef WIN32 char szExt[_MAX_EXT]; _splitpath_s(strFileName.c_str(), NULL,0, NULL,0, NULL, 0, szExt,_MAX_EXT); if (_stricmp(szExt,".jpg") && _stricmp(szExt,".png")) { strFileName += ext; } else ext = szExt; #endif #ifdef __APPLE__ if(!strcasecmp(ext.c_str(),".jpg")) { #else if(!_strcmpi(ext.c_str(),".jpg")) { #endif Dialog2 x(0,0,0,0,"ok"); quality = x.getValue(); } pDoc->saveImage(strFileName.c_str(), ext.c_str(), quality); } /*const char *szFileName = pDoc->m_pUI->m_chooser->value(); if (szFileName) { std::string strFileName = szFileName; std::string ext = (std::string)pDoc->m_pUI->m_chooser->filter(); ext = ext.substr(1, ext.length() - 1); #ifdef WIN32 char szExt[_MAX_EXT]; _splitpath_s(strFileName.c_str(), NULL,0, NULL,0, NULL, 0, szExt,_MAX_EXT); // If user didn't type supported ext, add default one. if (_stricmp(szExt,".jpg") && _stricmp(szExt,".png")) { strFileName += ext; } else ext = szExt; #endif int quality = 95; if (!strcmp(ext.c_str(),".jpg")){ Dialog2 x(0,0,0,0,"ok"); quality = x.getValue(); } pDoc->saveImage(strFileName.c_str(), ext.c_str(), quality); }*/ } //------------------------------------------------------------- // Brings up the paint dialog // This is called by the UI when the brushes menu item // is chosen //------------------------------------------------------------- void ImpressionistUI::cb_brushes(Fl_Menu_* o, void* v) { whoami(o)->m_brushDialog->show(); }
int yylex() { int c; while (1) { yytextclear(); int c; while ((c = fin.get()) == ' ' || c == '\t' || c == '\n') continue; if (c == '/') { if (fin.peek() == '*') { fin.get(); while (c = fin.get()) { if ((c == '*' && fin.peek() == '/') || c == '\n') break; } fin.get(); continue; } else yytext[0]='/'; yytext[1]=0; return DIVOP; //MULOP be * | / } if (c == EOF){ return EOFSY; } if (c == ':' && fin.peek() == '=') { yytext[0]=c; yytext[1]=fin.get(); yytext[2]=0; return ASSIGNOPP; } if (c == '('){ yytext[0] = '('; yytext[1]=0; return LPAREN; } if (c == ')'){ yytext[0] = ')'; yytext[1]=0; return RPAREN; } if (c == '+'){ yytext[0] = '+'; yytext[1]=0; return ADDOP; //ADDOP can be + | - } if (c == '-'){ yytext[0] = '-'; yytext[1]=0; return SUBOP; //ADDOP can be + | - } if (c == '*'){ yytext[0] = '*'; yytext[1]=0; return MULOP; //MULOP can be * | / } if (c >= '0' && c <= '9') { int dec = 0; yytext[0] = c; int i = 1; while (((c = fin.get()) >= '0' && c <= '9') || (c == '.')) { if (c == '.') dec++; if (dec == 2) throw exception(); yytext[i] = c; i++; } yytext[i]=0; fin.unget(); return NUMCONST; } else { yytext[0] = toupper(c); int i = 1; while ((c = fin.get()) != ' ' && c != '\t' && c != '\n' && c != EOF && c != ':' && c != '(' && c != ')' && c != '+' && c != '-' && c != '*' && c != '/') { yytext[i] = toupper(c); i++; } yytext[i] = 0; fin.unget(); if (_stricmp(yytext, "read") == 0) { return READSY; } if (_stricmp(yytext, "write") == 0) { return WRITESY; } return ID; } } }
BOOL freerdp_client_rdp_file_set_string(rdpFile* file, const char* name, const char* value, int index) { BOOL bStandard = TRUE; #ifdef DEBUG_CLIENT_FILE fprintf(stderr, "%s:s:%s\n", name, value); #endif if (_stricmp(name, "username") == 0) file->Username = _strdup(value); else if (_stricmp(name, "domain") == 0) file->Domain = _strdup(value); else if (_stricmp(name, "full address") == 0) file->FullAddress = _strdup(value); else if (_stricmp(name, "alternate full address") == 0) file->AlternateFullAddress = _strdup(value); else if (_stricmp(name, "usbdevicestoredirect") == 0) file->UsbDevicesToRedirect = _strdup(value); else if (_stricmp(name, "loadbalanceinfo") == 0) file->LoadBalanceInfo = _strdup(value); else if (_stricmp(name, "remoteapplicationname") == 0) file->RemoteApplicationName = _strdup(value); else if (_stricmp(name, "remoteapplicationicon") == 0) file->RemoteApplicationIcon = _strdup(value); else if (_stricmp(name, "remoteapplicationprogram") == 0) file->RemoteApplicationProgram = _strdup(value); else if (_stricmp(name, "remoteapplicationfile") == 0) file->RemoteApplicationFile = _strdup(value); else if (_stricmp(name, "remoteapplicationguid") == 0) file->RemoteApplicationGuid = _strdup(value); else if (_stricmp(name, "remoteapplicationcmdline") == 0) file->RemoteApplicationCmdLine = _strdup(value); else if (_stricmp(name, "alternate shell") == 0) file->AlternateShell = _strdup(value); else if (_stricmp(name, "shell working directory") == 0) file->ShellWorkingDirectory = _strdup(value); else if (_stricmp(name, "gatewayhostname") == 0) file->GatewayHostname = _strdup(value); else if (_stricmp(name, "kdcproxyname") == 0) file->KdcProxyName = _strdup(value); else if (_stricmp(name, "drivestoredirect") == 0) file->DrivesToRedirect = _strdup(value); else if (_stricmp(name, "devicestoredirect") == 0) file->DevicesToRedirect = _strdup(value); else if (_stricmp(name, "winposstr") == 0) file->WinPosStr = _strdup(value); else bStandard = FALSE; if (index >= 0) { file->lines[index].name = _strdup(name); file->lines[index].sValue = _strdup(value); file->lines[index].flags = RDP_FILE_LINE_FLAG_FORMATTED; file->lines[index].flags |= RDP_FILE_LINE_FLAG_TYPE_STRING; if (bStandard) file->lines[index].flags |= RDP_FILE_LINE_FLAG_STANDARD; file->lines[index].valueLength = 0; } return bStandard; }
int main(int argc, const char* argv[]) { if (argc < 1) { showUseage(); return 0; } const char* pszInputFileName = NULL; const char* pszOutputFileName = NULL; for (int i=1; i<argc; i++) { if (_stricmp(argv[i], "-i")==0 && i+1<argc) { pszInputFileName = argv[i+1]; i++; } else if (_stricmp(argv[i], "-o")==0 && i+1<argc) { pszOutputFileName = argv[i+1]; i++; } } if (pszInputFileName==NULL || pszOutputFileName==NULL) { showUseage(); return 0; } std::ifstream fin(pszInputFileName); std::ofstream fout(pszOutputFileName); if (!fin.is_open()) { std::cout << "Error(" << errno << ") can't open " << pszInputFileName << std::endl; return -1; } if (!fout.is_open()) { std::cout << "Error(" << errno << ") can't open " << pszOutputFileName << std::endl; return -2; } time_t tBegin = time(NULL); std::string line; unsigned long long idx = 0; while ( getline( fin, line)) { MD5_CTX ctx = {0}; MD5_Init(&ctx); MD5_Update(&ctx, line.c_str(), line.size()); unsigned char digest[16] = {0}; MD5_Final(digest, &ctx); char szMd5[32] = {0}; digest2String(digest, szMd5); #if 0 std::cout << "[" << idx << "]"; std::cout << " MD5("; std::cout << line.c_str(); std::cout << ")= " << szMd5 << std::endl; #endif fout << line << "\t\t" << szMd5 << std::endl; idx++; } fin.close(); fout.close(); time_t tEnd = time(NULL); unsigned int tCost = tEnd - tBegin; std::cout << "cal " << idx << "md5s cost" << tCost << " seconds" << std::endl; return 0; }
int HandleCommandLine(int argc, char *argv[]) { char FileDir[_MAX_PATH+1]; char sDependencies[4096]; int iRet, index; int i = 0; if( bService ) return 0; memset(FileDir, 0, sizeof(FileDir)); if( argc <= 1 ) { // Sem argumentos, inicia a aplicacao return 0; } // Interpreta os argumentos if( argc >= 2 ) { _strupr(argv[1]); if( _stricmp( argv[1], "INSTALL" ) == 0 ) { // Instala o Servico // Guarda o caminho para o diretorio corrente GetCurrentDirectory( sizeof(FileDir)-1, FileDir); //[13_04_2010>] // Seta o caminho para o nome de arquivo sprintf(FileDir,"%s\\%s.exe", FileDir, SERVICE_NAME); //[13_04_2010>] memset(sDependencies, 0, sizeof(sDependencies)); index = 0; for(i = 2; i < argc; i++){ strcpy(sDependencies+index, argv[ i ]); index = strlen(sDependencies) + 1; } iRet = InstallService( FileDir, SERVICE_NAME, (LPCTSTR)sDependencies); switch(iRet){ case 0: printf("Service already installed\n"); index = -1; break; case 1: printf("Install OK\n"); index = 1; break; case -1: printf("Install Error\n"); index = -1; break; } return index; } if( _stricmp( argv[1], "UNINSTALL" ) == 0 ) { iRet = UnInstallService( SERVICE_NAME ); switch(iRet){ case 0: printf("Service not found\n"); index = -1; break; case 1: printf("Uninstall OK\n"); index = 1; break; case -1: printf("Uninstall Error\n"); index = -1; break; } return index; } printf("\n"); printf("Command line to install the service: %s install <dependencies>\n\n", SERVICE_NAME); printf("Command line to remove the service: %s uninstall\n", SERVICE_NAME); return -1; } return 0; }
DWORD __fastcall ExInput::GameInput(wchar_t* wMsg) { static char In[400], *str, *tok; Misc::WideToChar(In, wMsg); str = strtok_s(In, " ", &tok); if (_stricmp(str, "#r") == 0) { str = strtok_s(NULL, " ", &tok); CreateThread(0, 0, &ExOOG::Rejoin, str, 0, 0); return -1; } #if _DEBUG if (_stricmp(str, "#icon") == 0) { ExEventTextMsg hEvent; hEvent.Argument = 0; hEvent.MsgType = EXEVENT_TEXTMSG; hEvent.Color = COL_RED; hEvent.wX = -1; hEvent.wY = 50; hEvent.Sound = 10; hEvent.P_A6 = 0xA6; int Dmg = 10000; sprintf_s(hEvent.szMsg, 255, "%d !", Dmg); hEvent.PacketLen = 0xE + strlen(hEvent.szMsg) + 1; static int eLen = 0; D2Funcs.D2NET_ReceivePacket(&eLen, (BYTE*)&hEvent, hEvent.PacketLen); return -1; } if (_stricmp(str, "#eventst") == 0) { ExEventTextMsg hEvent; hEvent.Argument = 0; hEvent.MsgType = EXEVENT_TEXTMSG; hEvent.Color = COL_RED; hEvent.wX = -1; hEvent.wY = 150; hEvent.Sound = 10; hEvent.P_A6 = 0xA6; int Dmg = 10000; sprintf_s(hEvent.szMsg, 255, "%d !", Dmg); hEvent.PacketLen = 0xE + strlen(hEvent.szMsg) + 1; ExEventOverhead hEvent2; hEvent2.MsgType = EXEVENT_OVERHEAD; hEvent2.Color = COL_WHITE; hEvent2.UnitId = D2Funcs.D2CLIENT_GetPlayer()->dwUnitId; hEvent2.P_A6 = 0xA6; _snprintf_s(hEvent2.szCellPath, 255, 255, "data\\D2Ex\\Blobs"); hEvent2.PacketLen = 0xE + strlen(hEvent2.szCellPath) + 1; static int eLen = 0; for (int i = 0; i < 4; ++i) { hEvent.Color = hEvent2.Color = rand() % 16; hEvent2.CellID = rand() % 4; D2Funcs.D2NET_ReceivePacket(&eLen, (BYTE*)&hEvent, hEvent.PacketLen); D2Funcs.D2NET_ReceivePacket(&eLen, (BYTE*)&hEvent2, hEvent2.PacketLen); } return -1; } if (_stricmp(str, "#icon2") == 0) { ExEventDownload pEvent = {}; pEvent.P_A6 = 0xA6; pEvent.MsgType = EXEVENT_DOWNLOAD; pEvent.bExec = 0; strcpy_s(pEvent.szURL, 255, "http://download.thinkbroadband.com/1GB.zip"); if (pEvent.szURL[0]) pEvent.PacketLen = 14 + strlen(pEvent.szURL) + 1; else pEvent.PacketLen = 15; static int eLen = 0; D2Funcs.D2NET_ReceivePacket(&eLen, (BYTE*)&pEvent, pEvent.PacketLen); return -1; } static exId test_ui[100] = {exnull_t}; if (strcmp(In, "#t1") == 0) { for (int i = 0; i < 100; ++i) { wostringstream str2; str2 << "Tescik " << i; test_ui[i] = gExGUI->add(new ExTextBox(10, 10 + (15 * i), COL_WHITE, 5, str2.str(), NULL)); } return -1; } if (strcmp(In, "#t2") == 0) { ExDownload::ShowHide(); } if (strcmp(In, "#t3") == 0) { auto test = blizz_unique_ptr<char>((char*)D2ASMFuncs::D2WIN_ReadFileFromMPQ("DATA\\LOCAL\\FONT\\LATIN\\README.TXT", NULL, NULL)); DEBUGMSG("Read text with data: %s", test) }
static PRT_BOOLEAN ParseCommandLine(int argc, char *argv[]) { for (int i = 1; i < argc; i++) { char* arg = argv[i]; if (arg[0] == '-' || arg[0] == '/') { if (_stricmp(arg + 1, "cooperative") == 0) { cooperative = PRT_TRUE; } else if (_stricmp(arg + 1, "threads") == 0) { if (i + 1 < argc) { threads = atoi(argv[++i]); if (threads <= 0) { threads = 1; } } } else if (_stricmp(arg + 1, "perf") == 0) { if (i + 1 < argc) { perf = PRT_TRUE; perfEndTime = atoi(argv[++i]); if (perfEndTime <= 0) { perfEndTime = 1; } } } else if (_stricmp(arg + 1, "w") == 0) { if (i + 1 < argc) { workspaceConfig = argv[++i]; } } else if (_stricmp(arg + 1, "arg") == 0) { if (i + 1 < argc) { parg = argv[++i]; } } else if (_stricmp(arg + 1, "h") == 0 || _stricmp(arg + 1, "help") == 0 || _stricmp(arg + 1, "?") == 0) { return PRT_FALSE; } else { printf("Unknown argument: '%s'\n", arg); return PRT_FALSE; } } else { printf("Unknown argument: '%s'\n", arg); return PRT_FALSE; } } return PRT_TRUE; }
int GCEventHook(WPARAM wParam,LPARAM lParam) { GCHOOK *gch = (GCHOOK*) lParam; gchat_contacts *gc = GetChat(gch->pDest->ptszID); UNREFERENCED_PARAMETER(wParam); if(gch) { if (!_stricmp(gch->pDest->pszModule, SKYPE_PROTONAME)) { switch (gch->pDest->iType) { case GC_SESSION_TERMINATE: { MCONTACT hContact; if (gc->mJoinedCount == 1) { // switch back to normal session // I don't know if this behaviour isn't a bit annoying, therefore, we // don't do this now, until a user requests this feature :) // open up srmm dialog when quit while 1 person left // CallService(MS_MSG_SENDMESSAGE, (WPARAM)gc->mJoinedContacts[0].hContact, 0); RemChatContact(gc, gc->mJoinedContacts[0].who); } // Delete Chatroom from Contact list, as we don't need it anymore...? if (hContact = find_chat(gc->szChatName)) CallService(MS_DB_CONTACT_DELETE, hContact, 0); RemChat(gc->szChatName); break; } case GC_USER_MESSAGE: if(gch && gch->ptszText && _tcslen(gch->ptszText) > 0) { DBVARIANT dbv, dbv2; CCSDATA ccs = {0}; TCHAR *pEnd; // remove the ending linebreak for (pEnd = &gch->ptszText[_tcslen(gch->ptszText) - 1]; *pEnd==_T('\r') || *pEnd==_T('\n'); pEnd--) *pEnd=0; // Send message to the chat-contact if (ccs.hContact = find_chat(gch->pDest->ptszID)) { #ifdef _UNICODE // If PREF_UTF is supported, just convert it to UTF8 and pass the buffer to PSS_MESSAGE if (mirandaVersion >= 0x070000) { ccs.lParam = (LPARAM)make_utf8_string(gch->ptszText); ccs.wParam = PREF_UTF; CallProtoService (SKYPE_PROTONAME, PSS_MESSAGE, 0, (LPARAM)&ccs); free ((void*)ccs.lParam); } else { // Otherwise create this strange dual miranda-format ccs.lParam = (LPARAM)calloc(3, _tcslen(gch->ptszText)+1); wcstombs ((char*)ccs.lParam, gch->ptszText, _tcslen(gch->ptszText)+1); _tcscpy ((TCHAR*)((char*)ccs.lParam+strlen((char*)ccs.lParam)+1), gch->ptszText); ccs.wParam = PREF_UNICODE; CallProtoService (SKYPE_PROTONAME, PSS_MESSAGE, 0, (LPARAM)&ccs); free ((void*)ccs.lParam); } #else ccs.lParam = (LPARAM)gch->ptszText; ccs.wParam = PREF_TCHAR; CallProtoService (SKYPE_PROTONAME, PSS_MESSAGE, 0, (LPARAM)&ccs); #endif } // Add our line to the chatlog GCDEST gcd = { gch->pDest->pszModule, gch->pDest->ptszID, 0 }; GCEVENT gce = { sizeof(gce), &gcd }; if ( _tcsncmp(gch->ptszText, _T("/me "), 4)==0 && _tcslen(gch->ptszText)>4) { gce.ptszText = gch->ptszText+4; gcd.iType = GC_EVENT_ACTION; } else { gce.ptszText = gch->ptszText; gcd.iType = GC_EVENT_MESSAGE; } if (db_get_ts(NULL, SKYPE_PROTONAME, "Nick", &dbv)) gce.ptszNick = TranslateT("Me"); else gce.ptszNick = dbv.ptszVal; db_get_ts(NULL, SKYPE_PROTONAME, SKYPE_NAME, &dbv2); gce.ptszUID = dbv2.ptszVal; gce.time = (DWORD)time(NULL); gce.dwFlags = GCEF_ADDTOLOG; gce.bIsMe = TRUE; CallService(MS_GC_EVENT, 0, (LPARAM)&gce); if (dbv.pszVal) db_free(&dbv); if (dbv2.pszVal) db_free(&dbv2); } break; case GC_USER_CHANMGR: InviteUser(gch->pDest->ptszID); break; case GC_USER_PRIVMESS: { MCONTACT hContact = find_contactT(gch->ptszUID); if (hContact) CallService(MS_MSG_SENDMESSAGE, hContact, 0); break; } case GC_USER_LOGMENU: switch(gch->dwData) { case 10: InviteUser(gch->pDest->ptszID); break; case 20: KillChatSession(gch->pDest); break; case 30: { TCHAR *ptr, buf[MAX_BUF]; ptr = SkypeGetT ("CHAT", (TCHAR*)gch->pDest->ptszID, "TOPIC"); _tcscpy(buf, ptr); free(ptr); if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_INPUTBOX), NULL, InputBoxDlgProc, (LPARAM)&buf)) SetChatTopic(gch->pDest->ptszID, buf, TRUE); break; } } break; case GC_USER_NICKLISTMENU: { MCONTACT hContact = find_contactT(gch->ptszUID); switch(gch->dwData) { case 10:CallService(MS_USERINFO_SHOWDIALOG, hContact, 0); break; case 20:CallService(MS_HISTORY_SHOWCONTACTHISTORY, hContact, 0); break; case 30: KickUser(hContact, gch); break; case 110: KillChatSession(gch->pDest); break; } break; } default: break; } } } return 0; }