您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetUserName函数代码示例

51自学网 2021-06-01 21:17:16
  C++
这篇教程C++ GetUserName函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GetUserName函数的典型用法代码示例。如果您正苦于以下问题:C++ GetUserName函数的具体用法?C++ GetUserName怎么用?C++ GetUserName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了GetUserName函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: getinfo

//.........这里部分代码省略.........        _stprintf(sBuf, _T("%02d"), osvi.dwUnderlyingMinorVersion);      else        _stprintf(sBuf, _T("%01d"), osvi.dwUnderlyingMinorVersion);    }    else      _stprintf(sBuf, _T("%01d"), osvi.dwUnderlyingMinorVersion / 10);    _tcscat(sText, sBuf);              if (osvi.dwUnderlyingBuildNumber)    {      _stprintf(sBuf, _T(" Build:%d"), osvi.dwUnderlyingBuildNumber);      _tcscat(sText, sBuf);    }    if (osvi.wUnderlyingServicePackMajor)           {      if (osvi.wUnderlyingServicePackMinor)             {        //Handle the special case of NT 4 SP 6a which Dtwinver ver treats as SP 6.1        if (os.IsNTPreWin2k(&osvi) && (osvi.wUnderlyingServicePackMajor == 6) && (osvi.wUnderlyingServicePackMinor == 1))          _stprintf(sBuf, _T(" Service Pack: 6a"));        //Handle the special case of XP SP 1a which Dtwinver ver treats as SP 1.1        else if (os.IsWindowsXP(&osvi) && (osvi.wUnderlyingServicePackMajor == 1) && (osvi.wUnderlyingServicePackMinor == 1))          _stprintf(sBuf, _T(" Service Pack: 1a"));        else          _stprintf(sBuf, _T(" Service Pack:%d.%d"), osvi.wUnderlyingServicePackMajor, osvi.wUnderlyingServicePackMinor);      }      else        _stprintf(sBuf, _T(" Service Pack:%d"), osvi.wUnderlyingServicePackMajor);      _tcscat(sText, sBuf);    }                                else    {      if (osvi.wUnderlyingServicePackMinor)               _stprintf(sBuf, _T(" Service Pack:0.%d"), osvi.wUnderlyingServicePackMinor);    }    _tcscat(sText, _T("/n"));        //Some extra info for CE  #ifdef UNDER_CE    if (osvi.UnderlyingPlatform == COSVersion::WindowsCE)    {      _tcscat(sText, _T("Model: "));      _tcscat(sText, osvi.szOEMInfo);      _tcscat(sText, _T("/nDevice Type: "));      _tcscat(sText, osvi.szPlatformType);    }  #endif*/   }  else    _stprintf(sText, _T("Failed in call to GetOSVersion/n"));             	char UserName[256+1]="";	DWORD Size=256+1;	if (GetUserName(UserName,&Size)!=0)	{		strcpy(mytext,"Current user : ");		strcat(mytext,UserName);	}	char ComputerName[256+1]="";	if (GetComputerName(ComputerName,&Size)!=0)	{		strcat(mytext,"/nComputerName : ");		strcat(mytext,ComputerName);	}	///////////////////////////////    char name[255];	char *IP=NULL;	PHOSTENT hostinfo;		if(gethostname(name, sizeof(name))==0)		{			if((hostinfo=gethostbyname(name)) != NULL)			{				IP = inet_ntoa(*(struct in_addr*)* hostinfo->h_addr_list);			}		}	if (IP)	{	strcat(mytext,"/nIP : ");	strcat(mytext,IP);	}	///////////////////////////////////////*	MEMORYSTATUS memoryStatus;	ZeroMemory(&memoryStatus,sizeof(MEMORYSTATUS));	memoryStatus.dwLength = sizeof (MEMORYSTATUS);		::GlobalMemoryStatus (&memoryStatus);		sprintf("Installed RAM: %ldMB",(DWORD) ceil(memoryStatus.dwTotalPhys/1024/1024));		sprintf("/r/nMemory Available: %ldKB",(DWORD) (memoryStatus.dwAvailPhys/1024));		sprintf("/r/nPrecent of used RAM: %%%ld/n",memoryStatus.dwMemoryLoad);	sprintf("/n");	sprintf(sText);*/	strcat(mytext,"/n");	strcat(mytext,sText);        return 0;}
开发者ID:JPG-Consulting,项目名称:uVNC,代码行数:101,


示例2: main

    int main(int argc,char* argv[])    {      DWORD dwType = REG_DWORD;      DWORD dwSize = sizeof(DWORD);	  DWORD dwNumber = 0;      char szUser[256];	exit(0);      HANDLE hPipe = 0;		if (argc > 1)			lsasspid=atoi(argv[1]);		if (argc > 2)			sscanf(argv[2],"%x",&MAGICESPINLSA);	  printf("Fun with debug registers. Written by Georgi Guninski/n");	  printf("vvdr started: lsasspid=%d breakp=%x/n",lsasspid,MAGICESPINLSA);   	  CreateThread(0, 0, &threadwriter, NULL, 0, 0);	  CreateThread(0, 0, &waitlsadie, NULL, 0, 0);	  CreateThread(0, 0, &threaddeb, NULL, 0, 0);  	  while(!lsadied);      printf("start %s/n",szPipe);      hPipe = CreateNamedPipe (szPipe, PIPE_ACCESS_DUPLEX,                               PIPE_TYPE_MESSAGE|PIPE_WAIT,                               2, 0, 0, 0, NULL);      if (hPipe == INVALID_HANDLE_VALUE)      {        printf ("Failed to create named pipe:/n  %s/n", szPipe);        return 3;      }	  CreateThread(0, 0, &threadlock, NULL, 0, 0);	  ConnectNamedPipe (hPipe, NULL);      if (!ReadFile (hPipe, (void *) &dwNumber, 4, &dwSize, NULL))      {        printf ("Failed to read the named pipe./n");        CloseHandle(hPipe);        return 4;      }     if (!ImpersonateNamedPipeClient (hPipe))      {        printf ("Failed to impersonate the named pipe./n");        CloseHandle(hPipe);        return 5;      }      dwSize  = 256;      GetUserName(szUser, &dwSize);      printf ("Impersonating dummy :) : %s/n/n/n/n", szUser);// the action begins	  FILE *f1;	  f1=fopen("c://winnt//system32//vv1.vv","a");		if (f1 != NULL)		{		 fprintf(f1,"lsass worked/n");		 fclose(f1);		 printf("/n%s/n","Done!");		}		else		 printf("error creating file");	fflush(stdout);	HKEY mykey;	RegCreateKey(HKEY_CLASSES_ROOT,"vv",&mykey);	RegCloseKey(mykey);    CloseHandle(hPipe);    return 0;    }
开发者ID:offensive-security,项目名称:exploit-database,代码行数:70,


示例3: ONlaunchEnvLocal

Module OMstatusONlaunchEnvLocal(OMconn conn, char *cmd, char *env){  OMdev indev, outdev;  int nsd, ansd, dummy;  struct sockaddr_un nad, target;  char basename[MAXPATHLEN];  char cmdline[MAXCMDLEN];  int i, len;  winInit();  nsd = socket(AF_UNIX, SOCK_STREAM, 0);  ZERO(nad);  nad.sun_family = AF_UNIX;  /* construct the basename of the UNIX socket */  /* FIXME */#ifndef WIN32  sprintf(basename, "%s%d", OM_UNIX_PATH, (int) getuid());#else  {    char tmp[255];    len = sizeof(tmp);    if (!GetUserName(tmp, &len)) {      sprintf(tmp, "winuser");    }    sprintf(basename, "%s%s", OM_UNIX_PATH, tmp);  }#endif  strcpy(nad.sun_path, basename);  /* try to bind */  len = strlen(basename);  for (i = 0; i < MAXNB; i++) {    sprintf(nad.sun_path + len, "_%d", i);    /* the +2 is still a mystery for me... */    if (bind(nsd, (struct sockaddr *) &nad, strlen(nad.sun_path) + 2) == 0) {      break;    }    else {      close(nsd);      nsd = socket(AF_UNIX, SOCK_STREAM, 0);      /* Check... */    }  }  /* store the socket name to pass to the server */  if (i < MAXNB)    sprintf(basename + len, "_%d", i);  else				/* FIXME */    ;  listen(nsd, 1);  /* Now, we can launch the service */  /* FIXME redirections ? */  sprintf(cmdline, "OM_CALLER_UNIX_SOCKET=%s %s &", basename, cmd);  system(cmdline);  /* and accept connections ... */  dummy = sizeof(target);  ansd = accept(nsd, (struct sockaddr *) &target, &dummy);  indev = OMmakeDevice(DEFAULT_ENCODING, OMmakeIOFd(ansd));  outdev = OMmakeDevice(DEFAULT_ENCODING, OMmakeIOFd(ansd));  conn->in = indev;  conn->out = outdev;  return OMsuccess;}
开发者ID:gap-packages,项目名称:openmath,代码行数:69,


示例4: LoadPrefs

void LoadPrefs(){	/**************************************************************************************************/	/*********************** Our Settings Section *****************************************************/	/**************************************************************************************************/	DWORD dBuff = 257;	TCHAR szUser[257];	GetUserName(szUser, &dBuff);	/**************************************************************************************************/	/*********************** Test if the file exists, If it doesn't, Create It ************************/	/**************************************************************************************************/	TCHAR XTRAY_INI_FILE[1024];#ifdef UNICODE	char temp[1024];	TCHAR TEMP_INI_FILE[1024];	_snprintf(temp, 1024, "%s//xtray.conf", xchat_get_info(ph, "xchatdir"));	ConvertString(temp, TEMP_INI_FILE, 1024);	if(FileExists(TEMP_INI_FILE))	{		_tcscpy(XTRAY_INI_FILE, TEMP_INI_FILE);	}	else	{		if(FileExists(BACKUP_INI_FILE))		{			_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);		}		else		{			HANDLE xTemp;			DWORD dwBytesTemp;			if(xTemp = CreateFile(TEMP_INI_FILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL))			{				if(GetLastError() != ERROR_ALREADY_EXISTS)				{					WriteFile(xTemp, _T("/xFF/xFE"), 4, &dwBytesTemp, NULL);				}				CloseHandle(xTemp);			}			if(FileExists(TEMP_INI_FILE))			{				_tcscpy(XTRAY_INI_FILE, TEMP_INI_FILE);			}			else			{				HANDLE xBackup;				DWORD dwBytesBackup;				if(xBackup = CreateFile(TEMP_INI_FILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL))				{					if(GetLastError() != ERROR_ALREADY_EXISTS)					{						WriteFile(xBackup, _T("/xFF/xFE"), 4, &dwBytesBackup, NULL);					}					CloseHandle(xBackup);				}				if(FileExists(BACKUP_INI_FILE))				{					_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);				}			}		}	}#else	_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);#endif	/**************************************************************************************************/	/*************************** Get the value for each of our preferances ****************************/	/**************************************************************************************************/	g_dwPrefs = GetPrivateProfileInt(szUser, _T("SETTINGS"),	0,  XTRAY_INI_FILE);	// backwards compatability	// also allows us to set defaults if its a new installation	// disable topic change, channel message and server notice by default	if(g_dwPrefs == 0)	{		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("HILIGHT"),		1,  XTRAY_INI_FILE)<<1);		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("INVITE"),		1,  XTRAY_INI_FILE)<<2);		/* g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("TOPIC"),		1,  XTRAY_INI_FILE)<<3); */		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("BANNED"),		1,  XTRAY_INI_FILE)<<4);		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("KICKED"),		1,  XTRAY_INI_FILE)<<5);		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("CTCP"),		1,  XTRAY_INI_FILE)<<6);		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("PMSG"),		1,  XTRAY_INI_FILE)<<7);		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("KILLED"),		1,  XTRAY_INI_FILE)<<8);		/* g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("NOTICE"),		1,  XTRAY_INI_FILE)<<9); */		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("DISCONNECT"),	1,  XTRAY_INI_FILE)<<10);		g_dwPrefs	|= (GetPrivateProfileInt(szUser, _T("AOM"),			0,  XTRAY_INI_FILE)<<11);//.........这里部分代码省略.........
开发者ID:JordanKinsley,项目名称:hexchat,代码行数:101,


示例5: UM_USER_CONTROLS

INT_PTR CRecreateDlg::RecreateDlgProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam){#define UM_USER_CONTROLS (WM_USER+121)#define UM_FILL_CMDLIST (WM_USER+122)	CRecreateDlg* pDlg = NULL;	if (messg == WM_INITDIALOG)	{		pDlg = (CRecreateDlg*)lParam;		pDlg->mh_Dlg = hDlg;		SetWindowLongPtr(hDlg, DWLP_USER, lParam);	}	else	{		pDlg = (CRecreateDlg*)GetWindowLongPtr(hDlg, DWLP_USER);	}	if (!pDlg)	{		return FALSE;	}	PatchMsgBoxIcon(hDlg, messg, wParam, lParam);	switch (messg)	{		case WM_INITDIALOG:		{			LRESULT lbRc = FALSE;			// Visual			SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hClassIcon);			SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hClassIconSm);			// Set password style (avoid "bars" on some OS)			SendDlgItemMessage(hDlg, tRunAsPassword, WM_SETFONT, (LPARAM)(HFONT)GetStockObject(DEFAULT_GUI_FONT), 0);			// Add menu items			HMENU hSysMenu = GetSystemMenu(hDlg, FALSE);			InsertMenu(hSysMenu, 0, MF_BYPOSITION, MF_SEPARATOR, 0);			InsertMenu(hSysMenu, 0, MF_BYPOSITION | MF_STRING | MF_ENABLED,					   ID_RESETCMDHISTORY, L"Clear history...");			InsertMenu(hSysMenu, 0, MF_BYPOSITION | MF_STRING | MF_ENABLED					   | (gpSet->isSaveCmdHistory ? MF_CHECKED : 0),					   ID_STORECMDHISTORY, L"Store history");									//#ifdef _DEBUG			//SetWindowPos(ghOpWnd, HWND_NOTOPMOST, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE);			//#endif			RConStartArgs* pArgs = pDlg->mp_Args;			_ASSERTE(pArgs);			// Fill command and task drop down			SendMessage(hDlg, UM_FILL_CMDLIST, TRUE, 0);			// Set text in command and folder fields			SetDlgItemText(hDlg, IDC_RESTART_CMD, pDlg->mpsz_DefCmd ? pDlg->mpsz_DefCmd : pArgs->pszSpecialCmd ? pArgs->pszSpecialCmd : L"");			SetDlgItemText(hDlg, IDC_STARTUP_DIR, pDlg->mpsz_DefDir ? pDlg->mpsz_DefDir : pArgs->pszStartupDir ? pArgs->pszStartupDir : gpConEmu->WorkDir());			// Split controls			if (pArgs->aRecreate == cra_RecreateTab)			{				// Hide Split's				ShowWindow(GetDlgItem(hDlg, gbRecreateSplit), SW_HIDE);				ShowWindow(GetDlgItem(hDlg, rbRecreateSplitNone), SW_HIDE);				ShowWindow(GetDlgItem(hDlg, rbRecreateSplit2Right), SW_HIDE);				ShowWindow(GetDlgItem(hDlg, rbRecreateSplit2Bottom), SW_HIDE);				ShowWindow(GetDlgItem(hDlg, stRecreateSplit), SW_HIDE);				ShowWindow(GetDlgItem(hDlg, tRecreateSplit), SW_HIDE);			}			else			{				// Fill splits				SetDlgItemInt(hDlg, tRecreateSplit, (1000-pArgs->nSplitValue)/10, FALSE);				CheckRadioButton(hDlg, rbRecreateSplitNone, rbRecreateSplit2Bottom, rbRecreateSplitNone+pArgs->eSplit);				EnableWindow(GetDlgItem(hDlg, tRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone));				EnableWindow(GetDlgItem(hDlg, stRecreateSplit), (pArgs->eSplit != pArgs->eSplitNone));			}			// Спрятать флажок "New window"			bool bRunInNewWindow_Hidden = (pArgs->aRecreate == cra_EditTab || pArgs->aRecreate == cra_RecreateTab);			ShowWindow(GetDlgItem(hDlg, cbRunInNewWindow), bRunInNewWindow_Hidden ? SW_HIDE : SW_SHOWNORMAL);			const wchar_t *pszUser = pArgs->pszUserName;			const wchar_t *pszDomain = pArgs->pszDomain;			bool bResticted = (pArgs->RunAsRestricted == crb_On);			int nChecked = rbCurrentUser;			DWORD nUserNameLen = countof(pDlg->ms_CurUser);			if (!GetUserName(pDlg->ms_CurUser, &nUserNameLen)) pDlg->ms_CurUser[0] = 0;			wchar_t szRbCaption[MAX_PATH*3];			lstrcpy(szRbCaption, L"Run as current &user: "); lstrcat(szRbCaption, pDlg->ms_CurUser);			SetDlgItemText(hDlg, rbCurrentUser, szRbCaption);//.........这里部分代码省略.........
开发者ID:rheostat2718,项目名称:conemu-maximus5,代码行数:101,


示例6: GetUserName

bool CUser::WriteConfig(CFile& File) {	File.Write("<User " + GetUserName().FirstLine() + ">/n");	if (m_eHashType != HASH_NONE) {		CString sHash = "md5";		if (m_eHashType == HASH_SHA256)			sHash = "sha256";		if (m_sPassSalt.empty()) {			PrintLine(File, "Pass", sHash + "#" + GetPass());		} else {			PrintLine(File, "Pass", sHash + "#" + GetPass() + "#" + m_sPassSalt + "#");		}	} else {		PrintLine(File, "Pass", "plain#" + GetPass());	}	PrintLine(File, "Nick", GetNick());	PrintLine(File, "AltNick", GetAltNick());	PrintLine(File, "Ident", GetIdent());	PrintLine(File, "RealName", GetRealName());	PrintLine(File, "BindHost", GetBindHost());	PrintLine(File, "DCCBindHost", GetDCCBindHost());	PrintLine(File, "QuitMsg", GetQuitMsg());	if (CZNC::Get().GetStatusPrefix() != GetStatusPrefix())		PrintLine(File, "StatusPrefix", GetStatusPrefix());	PrintLine(File, "Skin", GetSkinName());	PrintLine(File, "ChanModes", GetDefaultChanModes());	PrintLine(File, "Buffer", CString(GetBufferCount()));	PrintLine(File, "KeepBuffer", CString(KeepBuffer()));	PrintLine(File, "MultiClients", CString(MultiClients()));	PrintLine(File, "BounceDCCs", CString(BounceDCCs()));	PrintLine(File, "DenyLoadMod", CString(DenyLoadMod()));	PrintLine(File, "Admin", CString(IsAdmin()));	PrintLine(File, "DenySetBindHost", CString(DenySetBindHost()));	PrintLine(File, "DCCLookupMethod", CString((UseClientIP()) ? "client" : "default"));	PrintLine(File, "TimestampFormat", GetTimestampFormat());	PrintLine(File, "AppendTimestamp", CString(GetTimestampAppend()));	PrintLine(File, "PrependTimestamp", CString(GetTimestampPrepend()));	PrintLine(File, "TimezoneOffset", CString(m_fTimezoneOffset));	PrintLine(File, "JoinTries", CString(m_uMaxJoinTries));	PrintLine(File, "MaxJoins", CString(m_uMaxJoins));	PrintLine(File, "IRCConnectEnabled", CString(GetIRCConnectEnabled()));	File.Write("/n");	// Allow Hosts	if (!m_ssAllowedHosts.empty()) {		for (set<CString>::iterator it = m_ssAllowedHosts.begin(); it != m_ssAllowedHosts.end(); ++it) {			PrintLine(File, "Allow", *it);		}		File.Write("/n");	}	// CTCP Replies	if (!m_mssCTCPReplies.empty()) {		for (MCString::const_iterator itb = m_mssCTCPReplies.begin(); itb != m_mssCTCPReplies.end(); ++itb) {			PrintLine(File, "CTCPReply", itb->first.AsUpper() + " " + itb->second);		}		File.Write("/n");	}	// Modules	CModules& Mods = GetModules();	if (!Mods.empty()) {		for (unsigned int a = 0; a < Mods.size(); a++) {			CString sArgs = Mods[a]->GetArgs();			if (!sArgs.empty()) {				sArgs = " " + sArgs;			}			PrintLine(File, "LoadModule", Mods[a]->GetModName() + sArgs);		}		File.Write("/n");	}	// Servers	for (unsigned int b = 0; b < m_vServers.size(); b++) {		PrintLine(File, "Server", m_vServers[b]->GetString());	}	// Chans	for (unsigned int c = 0; c < m_vChans.size(); c++) {		CChan* pChan = m_vChans[c];		if (pChan->InConfig()) {			File.Write("/n");			if (!pChan->WriteConfig(File)) {				return false;			}		}	}	File.Write("</User>/n");	return true;}
开发者ID:bpcampbe,项目名称:znc,代码行数:98,


示例7: while

	void ServerConnection::thread()	{		while (!running)		{		#ifdef WIN32			Sleep(1);		#else			usleep(1000);		#endif		}		char hostname[1024] = "";		char applicationName[1024] = "";		char username[1024] = "";		#ifdef WIN32		gethostname(hostname, 1024);		::GetModuleFileName(0, applicationName, 1024);		DWORD username_len = 1024;		GetUserName(username, &username_len);		#endif		std::time_t startTime = std::time(nullptr);		bool lastConnected = true;		while (running)		{			struct sockaddr_in addr;			struct hostent* host;			std::string ipAddr = config["ip"];			host = gethostbyname(ipAddr.c_str());			if (host == NULL)			{				logger << "Could not look up host " << config["ip"] << "', are you connected to the internet?";				return;			}			addr.sin_family = host->h_addrtype;			memcpy((char*)&addr.sin_addr.s_addr, host->h_addr_list[0], host->h_length);			addr.sin_port = htons(config["port"]);			memset(addr.sin_zero, 0, 8);			SOCKET tempSocket = 0;			if ((tempSocket = socket(AF_INET, SOCK_STREAM, 0)) == -1)			{				logger << "Cannot create socket, try a reboot" << Log::newline;				closesocket(s);				#ifdef WIN32				Sleep(60000);				#else				sleep(60);				#endif				continue;			}			int rc;			int siz = sizeof(addr);			rc = ::connect(tempSocket, (struct sockaddr*) &addr, siz);			if (rc < 0)			{				if(lastConnected)					logger << "Could not connect to api host: " << config["ip"] << Log::newline;				lastConnected = false;				closesocket(tempSocket);				#ifdef WIN32				Sleep(1000);				#else				sleep(1);				#endif				continue;			}			lastConnected = true;			logger << "Connected to remote API" << Log::newline;			json packet;			packet["id"] = "session/start";			packet["data"]["host"] = hostname;			packet["data"]["file"] = applicationName;			packet["data"]["renderer"] = std::string((char*)renderer);			packet["data"]["starttime"] = (int)startTime;			packet["data"]["user"] = username;			send(packet, tempSocket);			s = tempSocket;			std::string buffer;			char buf[1024];			while (running && s != 0)			{				int rc = recv(s, buf, 1024, 0);				if (rc < 0)				{					closesocket(s);					s = 0;					break;				}				buffer += std::string(buf, rc);				while (buffer.size() > 4)				{//.........这里部分代码省略.........
开发者ID:Borf,项目名称:VrLib,代码行数:101,


示例8: sizeof

//.........这里部分代码省略.........				SetTimestampAppend(true);				SetTimestampPrepend(false);			} else if (sValue.Trim_n().Equals("prepend")) {				SetTimestampAppend(false);				SetTimestampPrepend(true);			} else if (sValue.Trim_n().Equals("false")) {				SetTimestampAppend(false);				SetTimestampPrepend(false);			} else {				SetTimestampFormat(sValue);			}		}	}	if (pConfig->FindStringEntry("dcclookupmethod", sValue))		SetUseClientIP(sValue.Equals("Client"));	pConfig->FindStringEntry("pass", sValue);	// There are different formats for this available:	// Pass = <plain text>	// Pass = <md5 hash> -	// Pass = plain#<plain text>	// Pass = <hash name>#<hash>	// Pass = <hash name>#<salted hash>#<salt>#	// 'Salted hash' means hash of 'password' + 'salt'	// Possible hashes are md5 and sha256	if (sValue.Right(1) == "-") {		sValue.RightChomp();		sValue.Trim();		SetPass(sValue, CUser::HASH_MD5);	} else {		CString sMethod = sValue.Token(0, false, "#");		CString sPass = sValue.Token(1, true, "#");		if (sMethod == "md5" || sMethod == "sha256") {			CUser::eHashType type = CUser::HASH_MD5;			if (sMethod == "sha256")				type = CUser::HASH_SHA256;			CString sSalt = sPass.Token(1, false, "#");			sPass = sPass.Token(0, false, "#");			SetPass(sPass, type, sSalt);		} else if (sMethod == "plain") {			SetPass(sPass, CUser::HASH_NONE);		} else {			SetPass(sValue, CUser::HASH_NONE);		}	}	CConfig::SubConfig subConf;	CConfig::SubConfig::const_iterator subIt;	pConfig->FindSubConfig("chan", subConf);	for (subIt = subConf.begin(); subIt != subConf.end(); ++subIt) {		const CString& sChanName = subIt->first;		CConfig* pSubConf = subIt->second.m_pSubConfig;		CChan* pChan = new CChan(sChanName, this, true, pSubConf);		if (!pSubConf->empty()) {			sError = "Unhandled lines in config for User [" + GetUserName() + "], Channel [" + sChanName + "]!";			CUtils::PrintError(sError);			CZNC::DumpConfig(pSubConf);			return false;		}		// Save the channel name, because AddChan		// deletes the CChannel*, if adding fails		sError = pChan->GetName();		if (!AddChan(pChan)) {			sError = "Channel [" + sError + "] defined more than once";			CUtils::PrintError(sError);			return false;		}		sError.clear();	}	pConfig->FindStringVector("loadmodule", vsList);	for (vit = vsList.begin(); vit != vsList.end(); ++vit) {		sValue = *vit;		CString sModName = sValue.Token(0);		// XXX Legacy crap, added in znc 0.089		if (sModName == "discon_kick") {			CUtils::PrintMessage("NOTICE: [discon_kick] was renamed, loading [disconkick] instead");			sModName = "disconkick";		}		CUtils::PrintAction("Loading Module [" + sModName + "]");		CString sModRet;		CString sArgs = sValue.Token(1, true);		bool bModRet = GetModules().LoadModule(sModName, sArgs, this, sModRet);		CUtils::PrintStatus(bModRet, sModRet);		if (!bModRet) {			sError = sModRet;			return false;		}		continue;	}	return true;}
开发者ID:bpcampbe,项目名称:znc,代码行数:101,


示例9: DEBUG

bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {	unsigned int a = 0;	sErrorRet.clear();	if (!User.IsValid(sErrorRet, true)) {		return false;	}	// user names can only specified for the constructor, changing it later	// on breaks too much stuff (e.g. lots of paths depend on the user name)	if (GetUserName() != User.GetUserName()) {		DEBUG("Ignoring username in CUser::Clone(), old username [" << GetUserName()				<< "]; New username [" << User.GetUserName() << "]");	}	if (!User.GetPass().empty()) {		SetPass(User.GetPass(), User.GetPassHashType(), User.GetPassSalt());	}	SetNick(User.GetNick(false));	SetAltNick(User.GetAltNick(false));	SetIdent(User.GetIdent(false));	SetRealName(User.GetRealName());	SetStatusPrefix(User.GetStatusPrefix());	SetBindHost(User.GetBindHost());	SetDCCBindHost(User.GetDCCBindHost());	SetQuitMsg(User.GetQuitMsg());	SetSkinName(User.GetSkinName());	SetDefaultChanModes(User.GetDefaultChanModes());	SetBufferCount(User.GetBufferCount(), true);	SetJoinTries(User.JoinTries());	SetMaxJoins(User.MaxJoins());	// Allowed Hosts	m_ssAllowedHosts.clear();	const set<CString>& ssHosts = User.GetAllowedHosts();	for (set<CString>::const_iterator it = ssHosts.begin(); it != ssHosts.end(); ++it) {		AddAllowedHost(*it);	}	for (a = 0; a < m_vClients.size(); a++) {		CClient* pSock = m_vClients[a];		if (!IsHostAllowed(pSock->GetRemoteIP())) {			pSock->PutStatusNotice("You are being disconnected because your IP is no longer allowed to connect to this user");			pSock->Close();		}	}	// !Allowed Hosts	// Servers	const vector<CServer*>& vServers = User.GetServers();	CString sServer;	CServer* pCurServ = GetCurrentServer();	if (pCurServ) {		sServer = pCurServ->GetName();	}	DelServers();	for (a = 0; a < vServers.size(); a++) {		CServer* pServer = vServers[a];		AddServer(pServer->GetName(), pServer->GetPort(), pServer->GetPass(), pServer->IsSSL());	}	m_uServerIdx = 0;	for (a = 0; a < m_vServers.size(); a++) {		if (sServer.Equals(m_vServers[a]->GetName())) {			m_uServerIdx = a + 1;			break;		}	}	if (m_uServerIdx == 0) {		m_uServerIdx = m_vServers.size();		CIRCSock* pSock = GetIRCSock();		if (pSock) {			PutStatus("Jumping servers because this server is no longer in the list");			pSock->Quit();		}	}	// !Servers	// Chans	const vector<CChan*>& vChans = User.GetChans();	for (a = 0; a < vChans.size(); a++) {		CChan* pNewChan = vChans[a];		CChan* pChan = FindChan(pNewChan->GetName());		if (pChan) {			pChan->SetInConfig(pNewChan->InConfig());		} else {			AddChan(pNewChan->GetName(), pNewChan->InConfig());		}	}	for (a = 0; a < m_vChans.size(); a++) {		CChan* pChan = m_vChans[a];//.........这里部分代码省略.........
开发者ID:bpcampbe,项目名称:znc,代码行数:101,


示例10: PRINT

voidWUploadThread::MessageReceived(const MessageRef & msg, const String & /* sessionID */){	PRINT("WUploadThread::MessageReceived/n");	switch (msg()->what)	{		case WTransfer::TransferCommandPeerID:		{			PRINT("WUpload::TransferCommandPeerID/n");			const char *id = NULL;                        if (msg()->FindString("beshare:FromSession", id) == B_OK)			{				fRemoteSessionID = QString::fromUtf8(id);				{					const char *name = NULL;                                        if (msg()->FindString("beshare:FromUserName", name) ==  B_OK)					{						QString user = QString::fromUtf8(name);						if ((user.isEmpty()) || (fRemoteUser == fRemoteSessionID))							fRemoteUser = GetUserName(fRemoteSessionID);						else							fRemoteUser = user;					}					else					{						fRemoteUser = GetUserName(fRemoteSessionID);					}				}				if (gWin->IsIgnored(fRemoteSessionID, true))				{					SetBlocked(true);				}				WUploadEvent *ui = new WUploadEvent(WUploadEvent::UpdateUI);				if (ui)				{//					ui->SetSession(id);					SendReply(ui);				}			}			bool c = false;                        if (!fTunneled && msg()->FindBool("unishare:supports_compression", c) == B_OK)			{				SetCompression(6);			}			double dpps = GetPacketSize() * 1024.0;			int32 pps = lrint(dpps);                        if ((msg()->FindInt32("unishare:preferred_packet_size", pps) == B_OK) && (pps < lrint(dpps)))				SetPacketSize((double) pps / 1024.0);			break;		}		case WTransfer::TransferFileList:		{			// TransferFileList(msg);			WMessageEvent *wme = new WMessageEvent(msg);			if (wme)			{				QApplication::postEvent(this, wme);			}			break;		}	}}
开发者ID:mtl1979,项目名称:unizone,代码行数:72,


示例11: par_setup_libpath

char *par_mktmpdir ( char **argv ) {    int i;    const char *tmpdir = NULL;    const char *key = NULL , *val = NULL;    /* NOTE: all arrays below are NULL terminated */    const char *temp_dirs[] = {         P_tmpdir, #ifdef WIN32        "C://TEMP", #endif        ".", NULL };    const char *temp_keys[] = { "PAR_TMPDIR", "TMPDIR", "TEMPDIR",                                  "TEMP", "TMP", NULL };    const char *user_keys[] = { "USER", "USERNAME", NULL };    const char *subdirbuf_prefix = "par-";    const char *subdirbuf_suffix = "";    char *progname = NULL, *username = NULL;    char *stmpdir = NULL, *top_tmpdir = NULL;    int f, j, k, stmp_len = 0;    char sha1[41];    SHA_INFO sha_info;    unsigned char buf[32768];    unsigned char sha_data[20];    if ( (val = par_getenv(PAR_TEMP)) && strlen(val) ) {        par_setup_libpath(val);        return strdup(val);    }#ifdef WIN32    {        DWORD buflen = MAXPATHLEN;        username = malloc(MAXPATHLEN);        GetUserName((LPTSTR)username, &buflen);        // FIXME this is uncondifionally overwritten below - WTF?    }#endif    /* Determine username */    username = get_username_from_getpwuid();    if ( !username ) { /* fall back to env vars */        for ( i = 0 ; username == NULL && (key = user_keys[i]); i++) {            if ( (val = par_getenv(key)) && strlen(val) )                 username = strdup(val);        }    }    if ( username == NULL )        username = "SYSTEM";       /* sanitize username: encode all bytes as 2 hex digits */    {        char *hexname = malloc(2 * strlen(username) + 1);        char *u, *h;        for ( u = username, h = hexname ; *u != '/0' ; u++, h += 2)            sprintf(h, "%02x", *(unsigned char*)u);        username = hexname;    }    /* Try temp environment variables */    for ( i = 0 ; tmpdir == NULL && (key = temp_keys[i]); i++ ) {        if ( (val = par_getenv(key)) && strlen(val) && isWritableDir(val) ) {            tmpdir = strdup(val);            break;        }    }#ifdef WIN32    /* Try the windows temp directory */    if ( tmpdir == NULL && (val = par_getenv("WinDir")) && strlen(val) ) {        char* buf = malloc(strlen(val) + 5 + 1);        sprintf(buf, "%s//temp", val);        if (isWritableDir(buf)) {            tmpdir = buf;        } else {            free(buf);        }    }#endif    /* Try default locations */    for ( i = 0 ; tmpdir == NULL && (val = temp_dirs[i]) && strlen(val) ; i++ ) {        if ( isWritableDir(val) ) {            tmpdir = strdup(val);        }    }    /* "$TEMP/par-$USER" */    stmp_len =         strlen(tmpdir) +        strlen(subdirbuf_prefix) +        strlen(username) +        strlen(subdirbuf_suffix) + 1024;    /* stmpdir is what we are going to return;        top_tmpdir is the top $TEMP/par-$USER, needed to build stmpdir.         NOTE: We need 2 buffers because snprintf() can't write to a buffer       it is also reading from. *///.........这里部分代码省略.........
开发者ID:gitpan,项目名称:PAR-Packer,代码行数:101,


示例12: globus_module_activate

void *mdsip_connect(char *host){  static int activated=0;  int status;  static globus_xio_stack_t stack_tcp;  static globus_xio_stack_t stack_gsi;  static globus_xio_driver_t tcp_driver;  static globus_xio_driver_t gsi_driver;  globus_result_t result;  globus_xio_handle_t xio_handle;  globus_xio_attr_t attr;  char *contact_string;  int is_gsi;  mdsip_message_t *m;  if (activated == 0)  {    result = globus_module_activate(GLOBUS_XIO_MODULE);    mdsip_test_status(0,result,"mdsip_connect globus_module_activate");    if (result != GLOBUS_SUCCESS) return 0;    result = globus_xio_driver_load("tcp",&tcp_driver);    mdsip_test_status(0,result,"mdsip_connect load tcp driver");    if (result != GLOBUS_SUCCESS) return 0;    result = globus_xio_driver_load("gsi",&gsi_driver);    mdsip_test_status(0,result,"mdsip_connect load gsi driver");    if (result != GLOBUS_SUCCESS) return 0;    result = globus_xio_stack_init(&stack_tcp, NULL);    mdsip_test_status(0,result,"mdsip_connect globus_xio_stack_init");    if (result != GLOBUS_SUCCESS) return 0;    result = globus_xio_stack_init(&stack_gsi, NULL);    mdsip_test_status(0,result,"mdsip_connect globus_xio_stack_init");    if (result != GLOBUS_SUCCESS) return 0;    result = globus_xio_stack_push_driver(stack_tcp, tcp_driver);    mdsip_test_status(0,result,"mdsip_connect globus_xio_stack_push_driver");    if (result != GLOBUS_SUCCESS) return 0;    result = globus_xio_stack_push_driver(stack_gsi, tcp_driver);    mdsip_test_status(0,result,"mdsip_connect globus_xio_stack_push_driver");    if (result != GLOBUS_SUCCESS) return 0;    result = globus_xio_stack_push_driver(stack_gsi, gsi_driver);    mdsip_test_status(0,result,"mdsip_connect globus_xio_stack_push_driver");    if (result != GLOBUS_SUCCESS) return 0;    activated = 1;  }  if (host == NULL || strlen(host) == 0)    return 0;  is_gsi = host[0] == '_';  result = globus_xio_handle_create(&xio_handle, is_gsi ? stack_gsi : stack_tcp);  mdsip_test_status(0,result,"mdsip_connect globus_xio_handle_create");  if (result != GLOBUS_SUCCESS) return 0;  contact_string = strcpy((char *)malloc(strlen(host)+10),&host[is_gsi ? 1 : 0]);    if (strstr(contact_string,":") == NULL)    strcat(contact_string,is_gsi ? ":8200" : ":8000");  result = globus_xio_attr_init(&attr);  mdsip_test_status(0,result,"mdsip_connect globus_xio_attr_init");  if (result != GLOBUS_SUCCESS) return 0;  if (is_gsi)  {    result = globus_xio_attr_cntl(attr,gsi_driver,GLOBUS_XIO_GSI_SET_DELEGATION_MODE,				  GLOBUS_XIO_GSI_DELEGATION_MODE_FULL);    mdsip_test_status(0,result,"mdsip_connect globus_xio_attr_cntl");    if (result != GLOBUS_SUCCESS) return 0;    result = globus_xio_attr_cntl(attr,			 gsi_driver,			 GLOBUS_XIO_GSI_SET_AUTHORIZATION_MODE,			 GLOBUS_XIO_GSI_HOST_AUTHORIZATION);    mdsip_test_status(0,result,"mdsip_connect globus_xio_attr_cntl");    if (result != GLOBUS_SUCCESS) return 0;  }  result = globus_xio_attr_cntl(attr,tcp_driver,GLOBUS_XIO_TCP_SET_SNDBUF,MDSIP_SNDBUF);  mdsip_test_status(0,result,"mdsip_connect SET_SNDBUF");  if (result != GLOBUS_SUCCESS) return 0;  result = globus_xio_attr_cntl(attr,tcp_driver,GLOBUS_XIO_TCP_SET_RCVBUF,MDSIP_RCVBUF);  mdsip_test_status(0,result,"mdsip_connect SET_RCVBUF");  if (result != GLOBUS_SUCCESS) return 0;  result = globus_xio_attr_cntl(attr,tcp_driver,GLOBUS_XIO_TCP_SET_NODELAY,GLOBUS_TRUE);  mdsip_test_status(0,result,"mdsip_connect SET_NODELAY");  if (result != GLOBUS_SUCCESS) return 0;  result = globus_xio_attr_cntl(attr,tcp_driver,GLOBUS_XIO_TCP_SET_KEEPALIVE,GLOBUS_TRUE);  mdsip_test_status(0,result,"mdsip_connect SET_KEEPALIVE");  if (result != GLOBUS_SUCCESS) return 0;  result = globus_xio_open(xio_handle, contact_string, attr);  mdsip_test_status(0,result,"mdsip_connect globus_xio_open");  if (result != GLOBUS_SUCCESS)     xio_handle = 0;  else  {#ifdef _WIN32    static char user[128];    int bsize=128;    char *user_p = GetUserName(user,&bsize) ? user : "Windows User";#elif __MWERKS__    static char user[128];    int bsize=128;    char *user_p = "Macintosh User";#elif __APPLE__    char *user_p;    struct passwd *pwd;//.........这里部分代码省略.........
开发者ID:dgarnier,项目名称:MDSplus-forked,代码行数:101,


示例13: Scan_clipboard

//------------------------------------------------------------------------------//http://msdn.microsoft.com/en-us/library/windows/desktop/ms649016%28v=vs.85%29.aspxDWORD WINAPI Scan_clipboard(LPVOID lParam){  //check if local or not :)  if (!LOCAL_SCAN)  {    h_thread_test[(unsigned int)lParam] = 0;    check_treeview(htrv_test, H_tests[(unsigned int)lParam], TRV_STATE_UNCHECK);//db_scan    return 0;  }  //db  sqlite3 *db = (sqlite3 *)db_scan;  if(!SQLITE_FULL_SPEED)sqlite3_exec(db_scan,"BEGIN TRANSACTION;", NULL, NULL, NULL);  //lecture du contenu du presse papier et extraction  if (OpenClipboard(0))  {    char description[MAX_LINE_SIZE], format[DEFAULT_TMP_SIZE],    data[MAX_LINE_SIZE],user[NB_USERNAME_SIZE+1]="";    unsigned int session_id = current_session_id;    HGLOBAL hMem;    //user    DWORD s=NB_USERNAME_SIZE;    GetUserName(user,&s);    int nb_items = CountClipboardFormats();    if (nb_items > 0)    {      unsigned int uFormat = EnumClipboardFormats(0);      #ifdef CMD_LINE_ONLY_NO_DB      printf("/"Clipboard/";/"format/";/"code/";/"description/";/"user/";/"session_id/";/"data/";/r/n");      #endif // CMD_LINE_ONLY_NO_DB      while (uFormat && start_scan && GetLastError() == ERROR_SUCCESS && --nb_items>0)      {        //check if ok        if (IsClipboardFormatAvailable(uFormat) == FALSE)        {          uFormat = EnumClipboardFormats(uFormat);          continue;        }        description[0] = 0;        data[0]= 0;        if (GetClipboardFormatName(uFormat, description, MAX_LINE_SIZE) != 0)        {          hMem = GetClipboardData(uFormat);          if (hMem != NULL)          {            switch(uFormat)            {              case CF_TEXT:                //format                strncpy(format,"CF_TEXT",DEFAULT_TMP_SIZE);                if (description[0]==0)strncpy(description,"Text",DEFAULT_TMP_SIZE);                //datas                strncpy(data,GlobalLock(hMem),MAX_LINE_SIZE);                convertStringToSQL(data, MAX_LINE_SIZE);                GlobalUnlock(hMem);                addClipboardtoDB(format, uFormat, description, data, user, session_id, db);              break;              case CF_BITMAP:                //format                strncpy(format,"CF_BITMAP",DEFAULT_TMP_SIZE);                if (description[0]==0)strncpy(description,"Bitmap Picture",DEFAULT_TMP_SIZE);                //do in bitmap to hexa                SaveBitmapToHexaStr((HBITMAP)hMem , data, MAX_LINE_SIZE);                addClipboardtoDB(format, uFormat, description, data, user, session_id, db);              break;              case CF_METAFILEPICT:                //format                strncpy(format,"CF_METAFILEPICT",DEFAULT_TMP_SIZE);                if (description[0]==0)strncpy(description,"Meta-File Picture",DEFAULT_TMP_SIZE);                //datas                DatatoHexa(GlobalLock(hMem), GlobalSize(hMem), data, MAX_LINE_SIZE);                addClipboardtoDB(format, uFormat, description, data, user, session_id, db);                GlobalUnlock(hMem);              break;              case CF_SYLK:                //format                strncpy(format,"CF_SYLK",DEFAULT_TMP_SIZE);                if (description[0]==0)strncpy(description,"Microsoft Symbolic Link (SYLK) data",DEFAULT_TMP_SIZE);                //datas                snprintf(data,MAX_LINE_SIZE,"%s",(char*)GlobalLock(hMem));                convertStringToSQL(data, MAX_LINE_SIZE);                GlobalUnlock(hMem);                addClipboardtoDB(format, uFormat, description, data, user, session_id, db);              break;              case CF_OEMTEXT:                //format                strncpy(format,"CF_OEMTEXT",DEFAULT_TMP_SIZE);                if (description[0]==0)strncpy(description,"Text (OEM)",DEFAULT_TMP_SIZE);                //datas                strncpy(data,GlobalLock(hMem),MAX_LINE_SIZE);                convertStringToSQL(data, MAX_LINE_SIZE);                GlobalUnlock(hMem);                addClipboardtoDB(format, uFormat, description, data, user, session_id, db);              break;//.........这里部分代码省略.........
开发者ID:treejames,项目名称:omnia-projetcs,代码行数:101,


示例14: imp_desktop_thread

DWORD WINAPI imp_desktop_thread(LPVOID lpParam){	vncServer *server = (vncServer *)lpParam;	HDESK desktop;	//vnclog.Print(LL_INTERR, VNCLOG("SelectDesktop /n"));	//vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop2 NULL/n"));	desktop = OpenInputDesktop(0, FALSE,								DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW |								DESKTOP_ENUMERATE | DESKTOP_HOOKCONTROL |								DESKTOP_WRITEOBJECTS | DESKTOP_READOBJECTS |								DESKTOP_SWITCHDESKTOP | GENERIC_WRITE								);	if (desktop == NULL)		vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop Error /n"));	else		vnclog.Print(LL_INTERR, VNCLOG("OpenInputdesktop OK/n"));	HDESK old_desktop = GetThreadDesktop(GetCurrentThreadId());	DWORD dummy;	char new_name[256];	if (!GetUserObjectInformation(desktop, UOI_NAME, &new_name, 256, &dummy))	{		vnclog.Print(LL_INTERR, VNCLOG("!GetUserObjectInformation /n"));	}	vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK to %s (%x) from %x/n"), new_name, desktop, old_desktop);	if (!SetThreadDesktop(desktop))	{		vnclog.Print(LL_INTERR, VNCLOG("SelectHDESK:!SetThreadDesktop /n"));	}//	ImpersonateCurrentUser_();	char m_username[UNLEN+1];	HWINSTA station = GetProcessWindowStation();	if (station != NULL)	{		DWORD usersize;		GetUserObjectInformation(station, UOI_USER_SID, NULL, 0, &usersize);		DWORD  dwErrorCode = GetLastError();		SetLastError(0);		if (usersize != 0)		{			DWORD length = sizeof(m_username);			if (GetUserName(m_username, &length) == 0)			{				UINT error = GetLastError();				if (error != ERROR_NOT_LOGGED_ON)				{					vnclog.Print(LL_INTERR, VNCLOG("getusername error %d/n"), GetLastError());					SetThreadDesktop(old_desktop);                	CloseDesktop(desktop);					Sleep(500);					return FALSE;				}			}		}	}    vnclog.Print(LL_INTERR, VNCLOG("Username %s /n"),m_username);	// Create tray icon and menu	vncMenu *menu = new vncMenu(server);	if (menu == NULL)	{		vnclog.Print(LL_INTERR, VNCLOG("failed to create tray menu/n"));		PostQuitMessage(0);	}	// This is a good spot to handle the old PostAdd messages	if (PostAddAutoConnectClient_bool)		vncService::PostAddAutoConnectClient( pszId_char );	if (PostAddAutoConnectClient_bool_null)		vncService::PostAddAutoConnectClient( NULL );	if (PostAddConnectClient_bool)		vncService::PostAddConnectClient( pszId_char );	if (PostAddConnectClient_bool_null)		vncService::PostAddConnectClient( NULL );	if (PostAddNewClient_bool)	{		PostAddNewClient_bool=false;		vnclog.Print(LL_INTERR, VNCLOG("PostAddNewClient IIIII/n"));		vncService::PostAddNewClient(address_vcard, port_int);	}	//adzm 2009-06-20	if (PostAddNewRepeaterClient_bool)	{		PostAddNewRepeaterClient_bool=false;		vnclog.Print(LL_INTERR, VNCLOG("PostAddNewRepeaterClient II/n"));		vncService::PostAddNewRepeaterClient();	}	bool Runonce=false;	MSG msg;	while (GetMessage(&msg,0,0,0) != 0)	{//.........这里部分代码省略.........
开发者ID:copilot-com,项目名称:UltraVNC,代码行数:101,


示例15: logThread

void logThread(void *dummy){	SetProcessPriorityBoost	(GetCurrentProcess(),TRUE);	logWindow = CreateDialog(		HINSTANCE(GetModuleHandle(0)),	 	MAKEINTRESOURCE(IDD_LOG),		0, logDlgProc );	if (!logWindow) {		R_CHK			(GetLastError());	};	SetWindowPos(logWindow,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_SHOWWINDOW);	hwLog		= GetDlgItem(logWindow, IDC_LOG);	hwProgress	= GetDlgItem(logWindow, IDC_PROGRESS);	hwInfo		= GetDlgItem(logWindow, IDC_INFO);	hwStage		= GetDlgItem(logWindow, IDC_STAGE);	hwTime		= GetDlgItem(logWindow, IDC_TIMING);	hwPText		= GetDlgItem(logWindow, IDC_P_TEXT);	hwPhaseTime	= GetDlgItem(logWindow, IDC_PHASE_TIME);	SendMessage(hwProgress, PBM_SETRANGE,	0, MAKELPARAM(0, 1000)); 	SendMessage(hwProgress, PBM_SETPOS,		0, 0); 	Msg("/"LevelBuilder v4.1/" beta build/nCompilation date: %s/n",__DATE__);	{		char tmpbuf[128];		Msg("Startup time: %s",_strtime(tmpbuf));	}	BOOL		bHighPriority	= FALSE;	string256	u_name;	unsigned long		u_size	= sizeof(u_name)-1;	GetUserName	(u_name,&u_size);	_strlwr		(u_name);	if ((0==xr_strcmp(u_name,"oles"))||(0==xr_strcmp(u_name,"alexmx")))	bHighPriority	= TRUE;	// Main cycle	u32		LogSize = 0;	float	PrSave	= 0;	while (TRUE)	{		SetPriorityClass	(GetCurrentProcess(),IDLE_PRIORITY_CLASS);	// bHighPriority?NORMAL_PRIORITY_CLASS:IDLE_PRIORITY_CLASS		// transfer data		while (!csLog.TryEnter())	{			_process_messages	( );			Sleep				(1);		}		if (progress>1.f)		progress = 1.f;		else if (progress<0)	progress = 0;		BOOL bWasChanges = FALSE;		char tbuf		[256];		csLog.Enter		();		if (LogSize!=LogFile->size())		{			bWasChanges		= TRUE;			for (; LogSize<LogFile->size(); LogSize++)			{				const char *S = *(*LogFile)[LogSize];				if (0==S)	S = "";				SendMessage	( hwLog, LB_ADDSTRING, 0, (LPARAM) S);			}			SendMessage		( hwLog, LB_SETTOPINDEX, LogSize-1, 0);			//FlushLog		( );		}		csLog.Leave		();		if (_abs(PrSave-progress)>EPS_L) {			bWasChanges = TRUE;			PrSave = progress;			SendMessage		( hwProgress, PBM_SETPOS, u32(progress*1000.f), 0);			// timing			if (progress>0.005f) {				u32 dwCurrentTime = timeGetTime();				u32 dwTimeDiff	= dwCurrentTime-phase_start_time;				u32 secElapsed	= dwTimeDiff/1000;				u32 secRemain		= u32(float(secElapsed)/progress)-secElapsed;				xr_sprintf(tbuf,					"Elapsed: %s/n"					"Remain:  %s",					make_time(secElapsed).c_str(),					make_time(secRemain).c_str()					);				SetWindowText	( hwTime, tbuf );			} else {				SetWindowText	( hwTime, "" );			}			// percentage text			xr_sprintf(tbuf,"%3.2f%%",progress*100.f);			SetWindowText	( hwPText, tbuf );		}		if (bStatusChange) {			bWasChanges		= TRUE;			bStatusChange	= FALSE;			SetWindowText	( hwInfo,	status);		}		if (bWasChanges) {//.........这里部分代码省略.........
开发者ID:AntonioModer,项目名称:xray-16,代码行数:101,


示例16: SavePrefs

void SavePrefs(int iDlg){	/**************************************************************************************************/	/********** allocate space for our string, and then set it to the currently logged on user ********/	/**************************************************************************************************/	DWORD dBuff = 257;	TCHAR szUser[257];	GetUserName(szUser, &dBuff);	/**************************************************************************************************/	/*********************** Test if the file exists, If it doesn't, Create It ************************/	/**************************************************************************************************/	TCHAR XTRAY_INI_FILE[1024];	#ifdef UNICODE	char temp[1024];    TCHAR TEMP_INI_FILE[1024];		_snprintf(temp, 1024, "%s//xtray.conf", xchat_get_info(ph, "xchatdir"));	ConvertString(temp, TEMP_INI_FILE, 1024);	// ok this one is really ugly	// it checks to see if the file exists in two locations	// HexChat default config dir, if that fails it tries hexchat/plugins/config	// if neither one exists it tries to create it in	// HexChat default config dir, if that fails it tries hexchat/plugins/config	// In either case it writes /xFF/xFE to the file ( on creation )	// so that we can save unicode away messages WritePrivateProfile doesn't 	// do this for us, though I think it really should	if(FileExists(TEMP_INI_FILE))	{		_tcscpy(XTRAY_INI_FILE, TEMP_INI_FILE);	}	else	{		if(FileExists(BACKUP_INI_FILE))		{			_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);		}		else		{			HANDLE xTemp;			DWORD dwBytesTemp;			if(xTemp = CreateFile(TEMP_INI_FILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL))			{				if(GetLastError() != ERROR_ALREADY_EXISTS)				{					WriteFile(xTemp, _T("/xFF/xFE"), 4, &dwBytesTemp, NULL);				}				CloseHandle(xTemp);			}			if(FileExists(TEMP_INI_FILE))			{				_tcscpy(XTRAY_INI_FILE, TEMP_INI_FILE);			}			else			{				HANDLE xBackup;				DWORD dwBytesBackup;				if(xBackup = CreateFile(TEMP_INI_FILE, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL))				{					if(GetLastError() != ERROR_ALREADY_EXISTS)					{						WriteFile(xBackup, _T("/xFF/xFE"), 4, &dwBytesBackup, NULL);					}					CloseHandle(xBackup);				}				if(FileExists(BACKUP_INI_FILE))				{					_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);				}			}		}	}#else	_tcscpy(XTRAY_INI_FILE, BACKUP_INI_FILE);#endif	WritePrivateProfileInt(szUser, _T("SETTINGS"),		g_dwPrefs,		XTRAY_INI_FILE);	WritePrivateProfileInt(szUser, _T("AOT"),			g_iTime,		XTRAY_INI_FILE);	WritePrivateProfileInt(szUser, _T("KEY"),			g_hHotKey.key,	XTRAY_INI_FILE);	WritePrivateProfileInt(szUser, _T("MOD"),			g_hHotKey.mod,	XTRAY_INI_FILE);	WritePrivateProfileString(szUser, _T("AWAY"),		g_szAway,		XTRAY_INI_FILE);}
开发者ID:JordanKinsley,项目名称:hexchat,代码行数:92,


示例17: HOST_NAME_MAX

void DatabaseOutputDriver::finalizeOutput() {	// This is where we'll send all the info we've received so far to the	// database	if (submittedResults) {		return; // Only submit results for a test once	}	//write the header if necessary	if (!wroteLogHeader) {		// get hostname and username for log header		// FIXME This needs to be platform-independent#ifndef HOST_NAME_MAX#define HOST_NAME_MAX (255)#endif		char hostname[HOST_NAME_MAX];		if (gethostname(hostname, HOST_NAME_MAX)) {			// TODO Handle error		}				std::string userName;#ifdef os_windows_test		char * szUserName = new char[MAX_USER_NAME + 1];		LPDWORD lpnSize = (LPDWORD)malloc(sizeof(DWORD));		*lpnSize = MAX_USER_NAME + 1;		if (lpnSize == NULL) {			fprintf(stderr, "[%s:%u] - Out of memory!/n", __FILE__, __LINE__);			// TODO Handle error;		}		memset(szUserName, 0, MAX_USER_NAME + 1);		if (!GetUserName(szUserName, lpnSize)) {			fprintf(stderr, "[%s:%u] - Failed to get username: %s/n",					__FILE__, __LINE__, GetLastError());			//TODO Handle error		}		userName = std::string(szUserName);		free(lpnSize);		delete [] szUserName;#else		//note: geteuid() is always successful		//FIXME: use getpwuid_r		struct passwd * pw = getpwuid(geteuid());		if (NULL == pw) {			//TODO unknown user			userName = "unknown";		} else {			userName = pw->pw_name;		}#endif		std::string logHeader = userName + "@" + hostname;                if (getenv("PLATFORM") != 0) {                    logHeader += "/nPLATFORM=";                    logHeader += getenv("PLATFORM");                }                logHeader += "/n/n";		FILE * sqlLog = fopen(sqlLogFilename.c_str(), "wb");		if (NULL == sqlLog) {			fprintf(stderr, "[%s:%u] - Error opening log file: %s/n",					__FILE__, __LINE__, sqlLogFilename.c_str());			//TODO handle error		}		int size = strlen(logHeader.c_str());		if (fwrite(logHeader.c_str(), sizeof(char), size, sqlLog) != size) {			fprintf(stderr, "[%s:%u] - Error writing to log file./n", __FILE__, __LINE__);			//TODO handle error		}		fclose(sqlLog);		wroteLogHeader = true;	}		writeSQLLog();	return;	//TODO: what about this stuff?	submittedResults = true;}
开发者ID:dyninst,项目名称:testsuite,代码行数:80,


示例18: DEBUG

bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneChans) {	unsigned int a = 0;	sErrorRet.clear();	if (!User.IsValid(sErrorRet, true)) {		return false;	}	// user names can only specified for the constructor, changing it later	// on breaks too much stuff (e.g. lots of paths depend on the user name)	if (GetUserName() != User.GetUserName()) {		DEBUG("Ignoring username in CUser::Clone(), old username [" << GetUserName()				<< "]; New username [" << User.GetUserName() << "]");	}	if (!User.GetPass().empty()) {		SetPass(User.GetPass(), User.GetPassHashType(), User.GetPassSalt());	}	SetNick(User.GetNick(false));	SetAltNick(User.GetAltNick(false));	SetIdent(User.GetIdent(false));	SetRealName(User.GetRealName());	SetStatusPrefix(User.GetStatusPrefix());	SetBindHost(User.GetBindHost());	SetDCCBindHost(User.GetDCCBindHost());	SetQuitMsg(User.GetQuitMsg());	SetSkinName(User.GetSkinName());	SetLanguage(User.GetLanguage());	SetDefaultChanModes(User.GetDefaultChanModes());	SetBufferCount(User.GetBufferCount(), true);	SetJoinTries(User.JoinTries());	SetMaxJoins(User.MaxJoins());	// Allowed Hosts	m_ssAllowedHosts.clear();	const set<CString>& ssHosts = User.GetAllowedHosts();	for (set<CString>::const_iterator it = ssHosts.begin(); it != ssHosts.end(); ++it) {		AddAllowedHost(*it);	}	for (a = 0; a < m_vClients.size(); a++) {		CClient* pSock = m_vClients[a];		if (!IsHostAllowed(pSock->GetRemoteIP())) {			pSock->PutStatusNotice("You are being disconnected because your IP is no longer allowed to connect to this user");			pSock->Close();		}	}	// !Allowed Hosts	// Networks	const vector<CIRCNetwork*>& vNetworks = User.GetNetworks();	for (a = 0; a < vNetworks.size(); a++) {		new CIRCNetwork(this, vNetworks[a], bCloneChans);	}	// !Networks	// CTCP Replies	m_mssCTCPReplies.clear();	const MCString& msReplies = User.GetCTCPReplies();	for (MCString::const_iterator it = msReplies.begin(); it != msReplies.end(); ++it) {		AddCTCPReply(it->first, it->second);	}	// !CTCP Replies	// Flags	SetIRCConnectEnabled(User.GetIRCConnectEnabled());	SetKeepBuffer(User.KeepBuffer());	SetMultiClients(User.MultiClients());	SetDenyLoadMod(User.DenyLoadMod());	SetAdmin(User.IsAdmin());	SetDenySetBindHost(User.DenySetBindHost());	SetTimestampAppend(User.GetTimestampAppend());	SetTimestampPrepend(User.GetTimestampPrepend());	SetTimestampFormat(User.GetTimestampFormat());	SetTimezoneOffset(User.GetTimezoneOffset());	// !Flags	// Modules	set<CString> ssUnloadMods;	CModules& vCurMods = GetModules();	const CModules& vNewMods = User.GetModules();	for (a = 0; a < vNewMods.size(); a++) {		CString sModRet;		CModule* pNewMod = vNewMods[a];		CModule* pCurMod = vCurMods.FindModule(pNewMod->GetModName());		if (!pCurMod) {			vCurMods.LoadModule(pNewMod->GetModName(), pNewMod->GetArgs(), CModInfo::UserModule, this, NULL, sModRet);		} else if (pNewMod->GetArgs() != pCurMod->GetArgs()) {			vCurMods.ReloadModule(pNewMod->GetModName(), pNewMod->GetArgs(), this, NULL, sModRet);		}	}	for (a = 0; a < vCurMods.size(); a++) {		CModule* pCurMod = vCurMods[a];		CModule* pNewMod = vNewMods.FindModule(pCurMod->GetModName());//.........这里部分代码省略.........
开发者ID:b3rend,项目名称:znc,代码行数:101,


示例19: usage

voidusage(void){	const char *env;	const char *user;#ifndef WIN32	struct passwd *pw = NULL;#endif	/* Find default user, in case we need it. */	user = getenv("PGUSER");	if (!user)	{#if !defined(WIN32) && !defined(__OS2__)		pw = getpwuid(geteuid());		if (pw)			user = pw->pw_name;		else		{			psql_error("could not get current user name: %s/n", strerror(errno));			exit(EXIT_FAILURE);		}#else							/* WIN32 */		char		buf[128];		DWORD		bufsize = sizeof(buf) - 1;		if (GetUserName(buf, &bufsize))			user = buf;#endif   /* WIN32 */	}	printf(_("psql is the PostgreSQL interactive terminal./n/n"));	printf(_("Usage:/n"));	printf(_("  psql [OPTION]... [DBNAME [USERNAME]]/n/n"));	printf(_("General options:/n"));	/* Display default database */	env = getenv("PGDATABASE");	if (!env)		env = user;	printf(_("  -c, --command=COMMAND    run only single command (SQL or internal) and exit/n"));	printf(_("  -d, --dbname=DBNAME      database name to connect to (default: /"%s/")/n"), env);	printf(_("  -f, --file=FILENAME      execute commands from file, then exit/n"));	printf(_("  -l, --list               list available databases, then exit/n"));	printf(_("  -v, --set=, --variable=NAME=VALUE/n"			 "                           set psql variable NAME to VALUE/n"));	printf(_("  -X, --no-psqlrc          do not read startup file (~/.psqlrc)/n"));	printf(_("  -1 (/"one/"), --single-transaction/n"			 "                           execute command file as a single transaction/n"));	printf(_("  --help                   show this help, then exit/n"));	printf(_("  --version                output version information, then exit/n"));	printf(_("/nInput and output options:/n"));	printf(_("  -a, --echo-all           echo all input from script/n"));	printf(_("  -e, --echo-queries       echo commands sent to server/n"));	printf(_("  -E, --echo-hidden        display queries that internal commands generate/n"));	printf(_("  -L, --log-file=FILENAME  send session log to file/n"));	printf(_("  -n, --no-readline        disable enhanced command line editing (readline)/n"));	printf(_("  -o, --output=FILENAME    send query results to file (or |pipe)/n"));	printf(_("  -q, --quiet              run quietly (no messages, only query output)/n"));	printf(_("  -s, --single-step        single-step mode (confirm each query)/n"));	printf(_("  -S, --single-line        single-line mode (end of line terminates SQL command)/n"));	printf(_("/nOutput format options:/n"));	printf(_("  -A, --no-align           unaligned table output mode/n"));	printf(_("  -F, --field-separator=STRING/n"	   "                           set field separator (default: /"%s/")/n"),		   DEFAULT_FIELD_SEP);	printf(_("  -H, --html               HTML table output mode/n"));	printf(_("  -P, --pset=VAR[=ARG]     set printing option VAR to ARG (see //pset command)/n"));	printf(_("  -R, --record-separator=STRING/n"	"                           set record separator (default: newline)/n"));	printf(_("  -t, --tuples-only        print rows only/n"));	printf(_("  -T, --table-attr=TEXT    set HTML table tag attributes (e.g., width, border)/n"));	printf(_("  -x, --expanded           turn on expanded table output/n"));	printf(_("/nConnection options:/n"));	/* Display default host */	env = getenv("PGHOST");	printf(_("  -h, --host=HOSTNAME      database server host or socket directory (default: /"%s/")/n"),		   env ? env : _("local socket"));	/* Display default port */	env = getenv("PGPORT");	printf(_("  -p, --port=PORT          database server port (default: /"%s/")/n"),		   env ? env : DEF_PGPORT_STR);	/* Display default user */	env = getenv("PGUSER");	if (!env)		env = user;	printf(_("  -U, --username=USERNAME  database user name (default: /"%s/")/n"), env);	printf(_("  -w, --no-password        never prompt for password/n"));	printf(_("  -W, --password           force password prompt (should happen automatically)/n"));	printf(_("/nFor more information, type /"//?/" (for internal commands) or /"//help/" (for SQL/n"			 "commands) from within psql, or consult the psql section in the PostgreSQL/n"			 "documentation./n/n"));	printf(_("Report bugs to <[email
C++ GetUserToolBarByIndex函数代码示例
C++ GetUserId函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。