• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ GetErrorString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: ClientAuthenticate

BOOL ClientAuthenticate(const char *name, const char *hostname)
{
	int rc, rcISC;
	SEC_WINNT_AUTH_IDENTITY nameAndPwd = {0};
	int bytesReceived = 0, bytesSent = 0;
	char myTokenSource[256];
	TimeStamp useBefore;
	DWORD ctxReq, ctxAttr;
	int dwRead,dwWritten;
	// input and output buffers
	SecBufferDesc obd, ibd;
	SecBuffer ob, ib[2];
	BOOL haveInbuffer = FALSE;
	BOOL haveContext = FALSE;
	SCHANNEL_CRED cred = {0};
	PCCERT_CONTEXT cert = NULL;

	HANDLE hMy = CertOpenSystemStore(0,"MY");
	if(!hMy)
	{
		rcISC = SEC_E_NO_CREDENTIALS;
		server_error(1,"[%08x] %s\n",rcISC,GetErrorString(rcISC));
		return FALSE;
    }

	if(name)
	{
		cert = CertFindCertificateInStore(hMy, X509_ASN_ENCODING, 0, CERT_FIND_SUBJECT_STR, (const wchar_t *)cvs::wide(name),	NULL);
		if(!cert)
		{
			rcISC = SEC_E_NO_CREDENTIALS;
			server_error(1,"No certificate for '%s': %s\n",name,GetErrorString(rcISC));
			return FALSE;
		}
	}

	cred.dwVersion = SCHANNEL_CRED_VERSION;
	cred.dwFlags = SCH_CRED_USE_DEFAULT_CREDS;

	if(cert)
	{
		cred.cCreds     = 1;
		cred.paCred     = &cert;
	}

	rc = AcquireCredentialsHandle( NULL, "SChannel", SECPKG_CRED_OUTBOUND, NULL, &cred, NULL, NULL, &credHandle, &useBefore );

	ctxReq = ISC_REQ_MANUAL_CRED_VALIDATION | ISC_REQ_INTEGRITY | ISC_REQ_CONFIDENTIALITY | ISC_REQ_REPLAY_DETECT | ISC_REQ_SEQUENCE_DETECT | ISC_REQ_STREAM | ISC_REQ_USE_SUPPLIED_CREDS;
	strncpy(myTokenSource,hostname,sizeof(myTokenSource));

	CertCloseStore(hMy,0);

	ib[0].pvBuffer = NULL;

	while ( 1 )
	{
		obd.ulVersion = SECBUFFER_VERSION;
		obd.cBuffers = 1;
		obd.pBuffers = &ob; // just one buffer
		ob.BufferType = SECBUFFER_TOKEN; // preping a token here
		ob.cbBuffer = secPackInfo->cbMaxToken;
		ob.pvBuffer = malloc(secPackInfo->cbMaxToken);

		rcISC = InitializeSecurityContext( &credHandle, haveContext? &contextHandle: NULL,
			myTokenSource, ctxReq, 0, SECURITY_NATIVE_DREP, haveInbuffer? &ibd: NULL,
			0, &contextHandle, &obd, &ctxAttr, &useBefore );

		if ( ib[0].pvBuffer != NULL )
		{
			free(ib[0].pvBuffer);
			ib[0].pvBuffer = NULL;
		}

		if ( rcISC == SEC_I_COMPLETE_AND_CONTINUE || rcISC == SEC_I_COMPLETE_NEEDED )
		{
			CompleteAuthToken( &contextHandle, &obd );
			if ( rcISC == SEC_I_COMPLETE_NEEDED )
				rcISC = SEC_E_OK;
			else if ( rcISC == SEC_I_COMPLETE_AND_CONTINUE )
				rcISC = SEC_I_CONTINUE_NEEDED;
		}

		if(rcISC<0)
		{
			server_error(1,"[%08x] %s\n",rcISC,GetErrorString(rcISC));
		}

		// send the output buffer off to the server
		if ( ob.cbBuffer != 0 )
		{
			if((dwWritten=tcp_write( (const char *) ob.pvBuffer, ob.cbBuffer))<=0)
				break;
			bytesSent += dwWritten;
		}
		free(ob.pvBuffer);
		ob.pvBuffer = NULL;
		ob.cbBuffer = 0;

		if ( rcISC != SEC_I_CONTINUE_NEEDED )
			break;
//.........这里部分代码省略.........
开发者ID:acml,项目名称:cvsnt,代码行数:101,代码来源:sserver_win32.cpp


示例2: DoSendPlain

void CTCPSocket :: DoSendPlain( fd_set *send_fd )
{
    if( m_Socket == INVALID_SOCKET || m_HasError || !m_Connected || m_SendBuffer.empty( ) )
        return;
    if( FD_ISSET( m_Socket, send_fd ) )
    {
        // socket is ready, send it

        int s = send( m_Socket, m_SendBuffer.c_str( ), (int)m_SendBuffer.size( ), MSG_NOSIGNAL );

        if( s > 0 )
        {
            // success! only some of the data may have been sent, remove it from the buffer

            if( !m_LogFile.empty( ) )
            {
                ofstream Log;
                Log.open( m_LogFile.c_str( ), ios :: app );

                if( !Log.fail( ) )
                {
                    Log << "SEND >>> " << m_SendBuffer.substr(0, s)  << endl;
                    Log.close( );
                }
            }
            m_SendBuffer = m_SendBuffer.substr( s );
            m_LastSend = GetTime( );
        }
        else if( s == SOCKET_ERROR && GetLastError( ) != EWOULDBLOCK )
        {
            // send error

            m_HasError = true;
            m_Error = GetLastError( );
            CONSOLE_Print( "[TCPSOCKET] error (send) - " + GetErrorString( ) );
            return;
        }
    }
}
开发者ID:cipriant,项目名称:OHSystem,代码行数:39,代码来源:socket.cpp


示例3: GetTabs

void CParser::ParseProcedureType(int nTabs,bool bParseProcedurePropertyType)
{	
	//int nTabs = 5;
	CString sToken = m_oToken.GetCurrentToken();
	m_sProgress = m_sProgress + GetTabs(nTabs) + 
		"ParseProcedureType " + sToken + "\r\n";
	if(IsProcedureType(sToken) == false)
	{	
		//m_sErrors = m_sErrors + "Error in file "+ m_sFile + 
		//		"\'s parsing procedure type\r\n";
		m_sProgress = m_sProgress + GetTabs(nTabs+1) 
			+ GetErrorString(); // + "\r\n";
	}
	else if(sToken == "Property" 
		&& bParseProcedurePropertyType == true)
	{				
		sToken = m_oToken.GetNextToken();		
		ParseProcedurePropertyType();		
	}

	m_oToken.GetNextToken();	
}
开发者ID:asakpke,项目名称:Parser-5-Compiler-Construction,代码行数:22,代码来源:Parser1.cpp


示例4: OnSignal

 void OnSignal(Entity * param0, const float3 & param1, const float3 & param2, float param3, float param4)
 {
     duk_context* ctx = ctx_;
     duk_push_global_object(ctx);
     duk_get_prop_string(ctx, -1, "_OnSignal");
     duk_remove(ctx, -2);
     duk_push_number(ctx, (size_t)key_);
     duk_push_array(ctx);
     PushWeakObject(ctx, param0);
     duk_put_prop_index(ctx, -2, 0);
     PushValueObjectCopy<float3>(ctx, param1, float3_ID, float3_Finalizer);
     duk_put_prop_index(ctx, -2, 1);
     PushValueObjectCopy<float3>(ctx, param2, float3_ID, float3_Finalizer);
     duk_put_prop_index(ctx, -2, 2);
     duk_push_number(ctx, param3);
     duk_put_prop_index(ctx, -2, 3);
     duk_push_number(ctx, param4);
     duk_put_prop_index(ctx, -2, 4);
     bool success = duk_pcall(ctx, 2) == 0;
     if (!success) LogError("[JavaScript] OnSignal: " + GetErrorString(ctx));
     duk_pop(ctx);
 }
开发者ID:realXtend,项目名称:tundra-urho3d,代码行数:22,代码来源:RigidBodyBindings.cpp


示例5: ConnectToNetworkDrive

void ConnectToNetworkDrive(const string& NewDir)
{
	string strRemoteName;
	DriveLocalToRemoteName(DRIVE_REMOTE_NOT_CONNECTED,NewDir[0],strRemoteName);
	string strUserName, strPassword;
	GetStoredUserName(NewDir[0], strUserName);
	NETRESOURCE netResource;
	netResource.dwType = RESOURCETYPE_DISK;
	netResource.lpLocalName = UNSAFE_CSTR(NewDir);
	netResource.lpRemoteName = UNSAFE_CSTR(strRemoteName);
	netResource.lpProvider = 0;
	DWORD res = WNetAddConnection2(&netResource, nullptr, EmptyToNull(strUserName.data()), 0);

	if (res == ERROR_SESSION_CREDENTIAL_CONFLICT)
		res = WNetAddConnection2(&netResource, nullptr, nullptr, 0);

	if (res)
	{
		for (;;)
		{
			if (!GetNameAndPassword(strRemoteName, strUserName, strPassword, nullptr, GNP_USELAST))
				break;

			res = WNetAddConnection2(&netResource, strPassword.data(), EmptyToNull(strUserName.data()), 0);

			if (!res)
				break;

			Global->CatchError();

			if (res != ERROR_ACCESS_DENIED && res != ERROR_INVALID_PASSWORD && res != ERROR_LOGON_FAILURE)
			{
				Message(MSG_WARNING, 1, MSG(MError), GetErrorString().data(), MSG(MOk));
				break;
			}
		}
	}
}
开发者ID:Frankie-666,项目名称:farmanager,代码行数:38,代码来源:network.cpp


示例6: DecodingFile

void DecodingFile(QString fPath, HCRYPTKEY hKey)
{
    QFile myFile(fPath);
    QString fName = myFile.fileName();

    QRegExp rx("[^eFile.dat]");
    int typeLen = 0;
    rx.indexIn(fName, typeLen);

    QFile srcFile("1" + fName.mid(0, typeLen));
    DWORD blockLen = 0, fDataSize;
    BYTE* fData;

    myFile.open(QIODevice::ReadOnly);
    if (!myFile.exists())
    {
        QMessageBox::critical(0, "Ошибка", "Файл не выбран", QMessageBox::Ok);
        return;
    }
    srcFile.open(QIODevice::WriteOnly);
    CryptDecrypt(hKey, 0, true, 0, NULL, &blockLen);
    fData = new BYTE[blockLen];
    memset(fData, 0, blockLen);
    while ((fDataSize = myFile.read((char*) fData, blockLen)))
    {
        if (!CryptDecrypt(hKey, 0, fDataSize < blockLen, 0, fData, &fDataSize))
        {
            QMessageBox::critical(0, "Ошибка", "Шифрование данных. " + GetErrorString(GetLastError()),
                                  QMessageBox::Ok);
            return;
        }
        srcFile.write((char*)fData, fDataSize);
        memset(fData, 0, blockLen);
    }
    delete[] fData;
    myFile.close();
    srcFile.close();
}
开发者ID:Naxik,项目名称:Lab2,代码行数:38,代码来源:widget.cpp


示例7: hid_error

LPCUSBSIO_API const wchar_t *I2C_Error(LPC_HANDLE handle, int32_t status)
{
    LPCUSBSIO_I2C_Ctrl_t *dev = (LPCUSBSIO_I2C_Ctrl_t *) handle;
    const wchar_t *retStr = NULL;
    
    if (validHandle(handle) != 0) 
    {
        if ((status == LPCUSBSIO_OK) || (LPCUSBSIO_ERR_HID_LIB == status)) 
        {
            retStr = hid_error(dev->hidDev);
        }
        else 
        {
            retStr = GetErrorString(status);
        }
    }
    else 
    {
        retStr = hid_error(NULL);
    }
    
    return retStr;
}
开发者ID:NXPNFCLinux,项目名称:linux_libnfc-nci,代码行数:23,代码来源:lpcusbsio.c


示例8: FindInitFunc

//------------------------------------------------------------------------------
InitFunc FindInitFunc(HMODULE &h, const wchar_t *fileName, ErrorReporter errorReporter)
{
    h = LoadLibrary(fileName);

    if (!h)
    {
        errorReporter((std::wstring(L"Failed to load DLL ") + fileName + L": " + GetErrorString()).c_str());
        return NULL;
    }
    
    static const std::string initFuncName("init_unit_test");
    
    InitFunc initFunc = reinterpret_cast<InitFunc>(GetProcAddress(h, initFuncName.c_str()));

    // Do not report error: it might be that DLL is just not Boost.Test-enabled.
    if (!initFunc)
    {
        FreeLibrary(h);
        h = NULL;
    }

    return initFunc;
}
开发者ID:ndl,项目名称:Gallio.BoostAdapter,代码行数:24,代码来源:BoostTestBridge.cpp


示例9: LOGERROR

void ScriptInterface::ReadJSONFile(const VfsPath& path, JS::MutableHandleValue out)
{
	if (!VfsFileExists(path))
	{
		LOGERROR("File '%s' does not exist", path.string8());
		return;
	}

	CVFSFile file;

	PSRETURN ret = file.Load(g_VFS, path);

	if (ret != PSRETURN_OK)
	{
		LOGERROR("Failed to load file '%s': %s", path.string8(), GetErrorString(ret));
		return;
	}

	std::string content(file.DecodeUTF8()); // assume it's UTF-8

	if (!ParseJSON(content, out))
		LOGERROR("Failed to parse '%s'", path.string8());
}
开发者ID:Rektosauros,项目名称:0ad,代码行数:23,代码来源:ScriptInterface.cpp


示例10: RecvFrom

void CUDPServer :: RecvFrom( fd_set *fd, struct sockaddr_in *sin, string *message )
{
	if( m_Socket == INVALID_SOCKET || m_HasError || !sin || !message ){
		
		return;
	}

	int AddrLen = sizeof( *sin );
	
	if( FD_ISSET( m_Socket, fd ) )
	{
		// data is waiting, receive it
		CONSOLE_Print( "DEBUUUUUUUUUUUUUUUUUUUUUG" );
		char buffer[1024];

#ifdef WIN32
		int c = recvfrom( m_Socket, buffer, 1024, 0, (struct sockaddr *)sin, &AddrLen );
#else
		int c = recvfrom( m_Socket, buffer, 1024, 0, (struct sockaddr *)sin, (socklen_t *)&AddrLen );
#endif

		if( c == SOCKET_ERROR && GetLastError( ) != EWOULDBLOCK )
		{
			// receive error

			m_HasError = true;
			m_Error = GetLastError( );
			CONSOLE_Print( "[UDPSERVER] error (recvfrom) - " + GetErrorString( ) );
		}
		else if( c > 0 )
		{
			// success!

			*message = string( buffer, c );
		}
	}
}
开发者ID:nyilmaz,项目名称:px-guard,代码行数:37,代码来源:socket.cpp


示例11: DoRecv

void CTCPSocket :: DoRecv( fd_set *fd )
{
	if( m_Socket == INVALID_SOCKET || m_HasError || !m_Connected )
		return;

	if( FD_ISSET( m_Socket, fd ) )
	{
		// data is waiting, receive it

		char buffer[1024];
		int c = recv( m_Socket, buffer, 1024, 0 );

		if( c == SOCKET_ERROR && GetLastError( ) != EWOULDBLOCK )
		{
			// receive error

			m_HasError = true;
			m_Error = GetLastError( );
			CONSOLE_Print( "[TCPSOCKET] error (recv) - " + GetErrorString( ) );
			return;
		}
		else if( c == 0 )
		{
			// the other end closed the connection

			CONSOLE_Print( "[TCPSOCKET] closed by remote host" );
			m_Connected = false;
		}
		else if( c > 0 )
		{
			// success! add the received data to the buffer

			m_RecvBuffer += string( buffer, c );
			m_LastRecv = GetTime( );
		}
	}
}
开发者ID:luqasn,项目名称:ghost4mac,代码行数:37,代码来源:socket.cpp


示例12: main

int main(int argc, char* argv[])
{
    SC_HANDLE  hSCManager = NULL, hService = NULL;
    char szImagePath[MAX_PATH];
	SERVICE_TABLE_ENTRY ServiceTable[] =
	{
		{ SERVICE_NAME, ServiceMain },
		{ NULL, NULL }
	};

	if(argc==1)
	{
		// Attempt to start service.  If this fails we're probably
		// not running as a service
		if(!StartServiceCtrlDispatcher(ServiceTable))
			return 0;
	}

	if(argc!=2 || (strcmp(argv[1],"-i") && strcmp(argv[1],"-u") && strcmp(argv[1],"-test") && strcmp(argv[1],"-v") && strcmp(argv[1],"-systray") ))
	{
		fprintf(stderr, "NT CVS Service Handler\n\n"
                        "Arguments:\n"
                        "\t%s -i\tInstall\n"
                        "\t%s -u\tUninstall\n"
                        "\t%s -test\tInteractive run"
                        "\t%s -v\tReport version number",
                        basename(argv[0]),basename(argv[0]),
                        basename(argv[0]), basename(argv[0]));
		return -1;
	}

    if (!strcmp(argv[1],"-v"))
	{
        puts(NTSERVICE_VERSION_STRING);
        return 0;
       }

	if(!strcmp(argv[1],"-i"))
	{
		// connect to  the service control manager
		if((hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE)) == NULL)
		{
			fprintf(stderr,"OpenSCManager Failed\n");
			return -1;
		}

		if((hService=OpenService(hSCManager,SERVICE_NAME,DELETE))!=NULL)
		{
			DeleteService(hService);
			CloseServiceHandle(hService);
		}

		GetModuleFileName(NULL,szImagePath,MAX_PATH);
		if ((hService = CreateService(hSCManager,SERVICE_NAME,DISPLAY_NAME,
						STANDARD_RIGHTS_REQUIRED|SERVICE_CHANGE_CONFIG, SERVICE_WIN32_OWN_PROCESS,
						SERVICE_AUTO_START, SERVICE_ERROR_NORMAL,
						szImagePath, NULL, NULL, NULL, NULL, NULL)) == NULL)
		{
			fprintf(stderr,"CreateService Failed: %s\n",GetErrorString());
			return -1;
		}
		{
			BOOL (WINAPI *pChangeServiceConfig2)(SC_HANDLE,DWORD,LPVOID);
			pChangeServiceConfig2=(BOOL (WINAPI *)(SC_HANDLE,DWORD,LPVOID))GetProcAddress(GetModuleHandle("advapi32"),"ChangeServiceConfig2A");
			if(pChangeServiceConfig2)
			{
				SERVICE_DESCRIPTION sd = { NTSERVICE_VERSION_STRING };
				pChangeServiceConfig2(hService,SERVICE_CONFIG_DESCRIPTION,&sd);
			}
		}
		CloseServiceHandle(hService);
		CloseServiceHandle(hSCManager);
		ReportError(FALSE,DISPLAY_NAME " installed successfully");
		printf(DISPLAY_NAME " installed successfully\n");
	}

	if(!strcmp(argv[1],"-u"))
	{
		// connect to  the service control manager
		if((hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE)) == NULL)
		{
			fprintf(stderr,"OpenSCManager Failed\n");
			return -1;
		}

		if((hService=OpenService(hSCManager,SERVICE_NAME,DELETE))==NULL)
		{
			fprintf(stderr,"OpenService Failed: %s\n",GetErrorString());
			return -1;
		}
		if(!DeleteService(hService))
		{
			fprintf(stderr,"DeleteService Failed: %s\n",GetErrorString());
			return -1;
		}
		CloseServiceHandle(hService);
		CloseServiceHandle(hSCManager);
		ReportError(FALSE,DISPLAY_NAME " uninstalled successfully");
		printf(DISPLAY_NAME " uninstalled successfully\n");
	}
//.........这里部分代码省略.........
开发者ID:pampersrocker,项目名称:G-CVSNT,代码行数:101,代码来源:ControlService.cpp


示例13: memset

Socket *Network::ConnectSocket(const char *address, unsigned short port, SocketTransportLayer transport)
{
	addrinfo *result = NULL;
	addrinfo *ptr = NULL;
	addrinfo hints;
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_INET;
	hints.ai_socktype = (transport == SocketOverTCP) ? SOCK_STREAM : SOCK_DGRAM;
	hints.ai_protocol = (transport == SocketOverTCP) ? IPPROTO_TCP : IPPROTO_UDP;

	char strPort[256];
	sprintf(strPort, "%d", (unsigned int)port);
	int ret = getaddrinfo(address, strPort, &hints, &result);
	if (ret != 0)
	{
		LOG(LogError, "Network::Connect: getaddrinfo failed: %s", GetErrorString(ret).c_str());
		return 0;
	}

#ifdef WIN32
	SOCKET connectSocket = WSASocket(result->ai_family, result->ai_socktype, result->ai_protocol,
		NULL, 0, WSA_FLAG_OVERLAPPED);
#else
	SOCKET connectSocket = socket(result->ai_family, result->ai_socktype, result->ai_protocol);
	LOG(LogInfo, "A call to socket() returned a new socket 0x%8X.", (unsigned int)connectSocket);
#endif
	if (connectSocket == INVALID_SOCKET)
	{
		LOG(LogError, "Network::Connect: Error at socket(): %s", GetLastErrorString().c_str());
		freeaddrinfo(result);
		return 0;
	}

	// Connect to server.
#ifdef WIN32
	ret = WSAConnect(connectSocket, result->ai_addr, (int)result->ai_addrlen, 0, 0, 0, 0);
#else
	ret = connect(connectSocket, result->ai_addr, (int)result->ai_addrlen);
#endif

	if (ret == KNET_SOCKET_ERROR)
	{
		closesocket(connectSocket);
		connectSocket = INVALID_SOCKET;
	}

	freeaddrinfo(result);

	if (connectSocket == INVALID_SOCKET)
	{
		LOG(LogError, "Unable to connect to server!");
		return 0;
	}

	EndPoint localEndPoint;
	sockaddr_in sockname;
	socklen_t socknamelen = sizeof(sockname);
	ret = getsockname(connectSocket, (sockaddr*)&sockname, &socknamelen);
	if (ret == 0)
		 localEndPoint = EndPoint::FromSockAddrIn(sockname);
	else
		LOG(LogError, "Network::ConnectSocket: getsockname failed: %s!", Network::GetLastErrorString().c_str());

	EndPoint remoteEndPoint;
	sockaddr_in peername;
	socklen_t peernamelen = sizeof(peername);
	ret = getpeername(connectSocket, (sockaddr*)&peername, &peernamelen);
	if (ret == 0)
		remoteEndPoint = EndPoint::FromSockAddrIn(peername);
	else
		LOG(LogError, "Network::ConnectSocket: getpeername failed: %s!", Network::GetLastErrorString().c_str());

	std::string remoteHostName = remoteEndPoint.IPToString();

	const size_t maxSendSize = (transport == SocketOverTCP) ? cMaxTCPSendSize : cMaxUDPSendSize;
	Socket socket(connectSocket, localEndPoint, localHostName.c_str(), remoteEndPoint, remoteHostName.c_str(), transport, ClientSocket, maxSendSize);

	socket.SetBlocking(false);
	sockets.push_back(socket);

	Socket *sock = &sockets.back();

	return sock;
}
开发者ID:edwardt,项目名称:kNet,代码行数:84,代码来源:Network.cpp


示例14: iwmx_sdk_connect

/*
 * Connect to a network
 *
 * This function starts the connection process to a given network;
 * when the device changes status, the status change callback will
 * tell NetworkManager if the network is finally connected or not.
 *
 * One of the reasons it is done like that is to allow external tools
 * to control the device and the plugin just passing the status so
 * NetworkManager displays the right info.
 */
int iwmx_sdk_connect(struct wmxsdk *wmxsdk, const char *nsp_name)
{
	int result = 0;

	WIMAX_API_RET r;
	char errstr[512];
	UINT32 errstr_size = sizeof(errstr);
	WIMAX_API_DEVICE_STATUS dev_status;
	char sdk_name[MAX_SIZE_OF_NSP_NAME];

	g_mutex_lock(&wmxsdk->connect_mutex);
	/* Guess what the current radio state is; if it is ON
	 * already, don't redo it. */
	dev_status = iwmxsdk_status_get(wmxsdk);
	if ((int) dev_status < 0) {
		result = dev_status;
		goto error_get_status;
	}
	switch (dev_status) {
	case WIMAX_API_DEVICE_STATUS_UnInitialized:
		nm_log_err(LOGD_WIMAX, "wmxsdk: SW BUG? HW is uninitialized");
		result = -EINVAL;
		goto error_cant_do;
	case WIMAX_API_DEVICE_STATUS_RF_OFF_HW_SW:
	case WIMAX_API_DEVICE_STATUS_RF_OFF_HW:
	case WIMAX_API_DEVICE_STATUS_RF_OFF_SW:
		nm_log_err(LOGD_WIMAX, "wmxsdk: Cannot connect: radio is off");
		result = -EPERM;
		goto error_cant_do;
	case WIMAX_API_DEVICE_STATUS_Ready:
	case WIMAX_API_DEVICE_STATUS_Scanning:
		break;
	case WIMAX_API_DEVICE_STATUS_Connecting:
		nm_log_dbg(LOGD_WIMAX, "Connect already pending, waiting for it");
		result = -EINPROGRESS;
		goto error_cant_do;
	case WIMAX_API_DEVICE_STATUS_Data_Connected:
		nm_log_err(LOGD_WIMAX, "wmxsdk: BUG? need to disconnect?");
		result = -EINVAL;
		goto error_cant_do;
	default:
		g_assert(1);
	}

	/* The SDK treats the network name as wchar_t* while the contents are
	 * actually just UTF-8...  WTF?  Hand it a full buffer to work around
	 * boundary cases where the NSP name contains an odd # of characters.
	 */
	memset(sdk_name, 0, sizeof (sdk_name));
	memcpy(sdk_name, nsp_name, strlen (nsp_name));

	/* Ok, do the connection, wait for a callback */
	r = CmdConnectToNetwork(&wmxsdk->device_id, &sdk_name[0], 0, 0);
	if (r != WIMAX_API_RET_SUCCESS) {
		GetErrorString(&wmxsdk->device_id, r, errstr, &errstr_size);
		nm_log_err(LOGD_WIMAX, "wmxsdk: Cannot connect to network %s: %d (%s) - device is in state '%s'",
		           nsp_name, r, errstr,
		           iwmx_sdk_get_device_status_str(wmxsdk));
		result = -EIO;
	}

error_cant_do:
error_get_status:
	g_mutex_unlock(&wmxsdk->connect_mutex);
	return result;
}
开发者ID:aelarabawy,项目名称:NetworkManager,代码行数:77,代码来源:iwmxsdk.c


示例15: GetCurrentLineNumber

void XmlParser::OnParseError ()
{
    ex::fprintf( stderr, "%s Parse error at line %d: %s\n", m_ParsingFileName, GetCurrentLineNumber(), GetErrorString() );
    ex_error( "%s Parse error at line %d: %s\n", m_ParsingFileName, GetCurrentLineNumber(), GetErrorString() );
}
开发者ID:darkfall,项目名称:exlibs,代码行数:5,代码来源:XmlParser.cpp


示例16: GetErrorString

static char *GetLastErrorString( void )
{
	return GetErrorString( GetLastError() );
}
开发者ID:BackupTheBerlios,项目名称:wl530g-svn,代码行数:4,代码来源:ntservice.c


示例17: GetErrorString

std::string Network::GetLastErrorString()
{
	return GetErrorString(GetLastError());
}
开发者ID:edwardt,项目名称:kNet,代码行数:4,代码来源:Network.cpp


示例18: keyV

void Widget::on_decryptFile_clicked()
{
    HCRYPTPROV cryptProv;
    HCRYPTKEY hKey;
    BYTE* key;
    QFile keyV("key.dat");
    DWORD keyBlobLen = 0;
    if (!keyV.exists())
    {
        QMessageBox::critical(0, "Ошибка", "Отсутствует ключ", QMessageBox::Ok);
        return;
    }
    keyV.open(QIODevice::ReadOnly);

    if (!CryptAcquireContext(&cryptProv, NULL, MS_DEF_RSA_SCHANNEL_PROV, PROV_RSA_SCHANNEL, CRYPT_VERIFYCONTEXT))
    {
        QMessageBox::critical(0, "Ошибка", "Получение контекста криптопровайдера. " + GetErrorString(GetLastError()), QMessageBox::Ok);
        return;
    }
    keyV.read((char *)&keyBlobLen, sizeof(keyBlobLen));
    key = new BYTE[keyBlobLen];
    memset(key, 0, keyBlobLen);
    keyV.read((char *)key, keyBlobLen);
    keyV.close();
    CryptImportKey(cryptProv, key, keyBlobLen, 0, 0, &hKey);
    delete[] key;
    DecodingFile(fName, hKey);
    QMessageBox::information(0, "Процесс завершён", "Файл успешно расшифрован", QMessageBox::Ok);
}
开发者ID:Naxik,项目名称:Lab2,代码行数:29,代码来源:widget.cpp


示例19: Connect

void CTCPClient :: Connect( string localaddress, string address, uint16_t port )
{
	if( m_Socket == INVALID_SOCKET || m_HasError || m_Connecting || m_Connected )
		return;

	if( !localaddress.empty( ) )
	{
		struct sockaddr_in LocalSIN;
		memset( &LocalSIN, 0, sizeof( LocalSIN ) );
		LocalSIN.sin_family = AF_INET;

		if( ( LocalSIN.sin_addr.s_addr = inet_addr( localaddress.c_str( ) ) ) == INADDR_NONE )
			LocalSIN.sin_addr.s_addr = INADDR_ANY;

		LocalSIN.sin_port = htons( 0 );

		if( bind( m_Socket, (struct sockaddr *)&LocalSIN, sizeof( LocalSIN ) ) == SOCKET_ERROR )
		{
			m_HasError = true;
			m_Error = GetLastError( );
			CONSOLE_Print( "[TCPCLIENT] error (bind) - " + GetErrorString( ) );
			return;
		}
	}

	// get IP address

	struct hostent *HostInfo;
	uint32_t HostAddress;
	HostInfo = gethostbyname( address.c_str( ) );

	if( !HostInfo )
	{
		m_HasError = true;
		// m_Error = h_error;
		CONSOLE_Print( "[TCPCLIENT] error (gethostbyname)" );
		return;
	}

	memcpy( &HostAddress, HostInfo->h_addr, HostInfo->h_length );

	// connect

	m_SIN.sin_family = AF_INET;
	m_SIN.sin_addr.s_addr = HostAddress;
	m_SIN.sin_port = htons( port );

	if( connect( m_Socket, (struct sockaddr *)&m_SIN, sizeof( m_SIN ) ) == SOCKET_ERROR )
	{
		if( GetLastError( ) != EINPROGRESS && GetLastError( ) != EWOULDBLOCK )
		{
			// connect error

			m_HasError = true;
			m_Error = GetLastError( );
			CONSOLE_Print( "[TCPCLIENT] error (connect) - " + GetErrorString( ) );
			return;
		}
	}

	m_Connecting = true;
}
开发者ID:Mofsy,项目名称:ent-ghost,代码行数:62,代码来源:socket.cpp


示例20: T2COLE

BOOL CChildFrame::OpenCompositeDocument(LPCTSTR lpszFileName) 
{ 
    USES_CONVERSION; 

    CWaitCursor wait; 

    HRESULT hResult = E_FAIL; 
    IStorage * ptrRootStg = NULL; // root storage 
    HWND hWnd = (HWND)m_hWnd; 

    hResult = ::StgIsStorageFile( T2COLE(m_szFileName) ); 
    if( S_OK != hResult ) 
    { 
        TCHAR szFmt[MAX_PATH] = { 0 }; 
        AtlLoadString(IDS_OPEN_ARCHIVE_ERROR, szFmt, _countof(szFmt)); 

        TCHAR szOut[MAX_PATH*2] = { 0 }; 
        wnsprintf(szOut, _countof(szOut), szFmt, lpszFileName); 

        AtlMessageBox(m_hWnd, szOut, IDS_ERROR, MB_OK|MB_ICONSTOP); 
        return FALSE; 
    }

    // open the Compound document 
    hResult = ::StgOpenStorage( T2COLE(m_szFileName), NULL, 
        STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 
        0, 0, &ptrRootStg ); 
    if( FAILED(hResult) )
    { 
        TCHAR szFmt[MAX_PATH] = { 0 }; 
        AtlLoadString(IDS_OPEN_FILE_ERROR, szFmt, _countof(szFmt)); 

        TCHAR szError[MAX_PATH] = { 0 }; 

        TCHAR szOut[MAX_PATH*2] = { 0 }; 
        wnsprintf(szOut, _countof(szOut), szFmt, 
            lpszFileName, GetErrorString(S_OK, szError, _countof(szError))); 

        AtlMessageBox(m_hWnd, szOut, IDS_ERROR, MB_OK|MB_ICONSTOP); 
        return FALSE;
    } 

    TREE_ITEM_DATA * pRootData = new TREE_ITEM_DATA(ptrRootStg, STGTY_STORAGE); 

    HTREEITEM hRoot = m_wndCatalog.InsertItem ( 
        TVIF_IMAGE|TVIF_TEXT|TVIF_PARAM|TVIF_SELECTEDIMAGE, 
        PathFindFileName(m_szFileName), 
        0, 1, TVIS_EXPANDED, 0, 
        reinterpret_cast<LPARAM>(pRootData), 
        NULL, NULL); 


    std::stack < StgInfo > FolderStack; 
    HTREEITEM htiParent = hRoot; 
    IEnumSTATSTG * ptrEnum = NULL; 

    hResult = ptrRootStg->EnumElements( 0, NULL, 0, &ptrEnum ); 
    if( FAILED(hResult) ) { 
        ptrRootStg->Release(); 
        return 0; 
    } 

    TCHAR szSwap[MAX_PATH] = { 0 }; 

	LARGE_INTEGER nStorageLength;
	nStorageLength.QuadPart = 0;
    STATSTG StatStg = { 0 }; 
    while( S_OK == hResult ) 
    { 
        hResult = ptrEnum->Next( 1, &StatStg, NULL ); 
        if( S_FALSE == hResult ) 
        { 
            ptrRootStg->Release(); 
            ptrEnum->Release(); 

            // m_wndCatalog.Expand(strFolder); 

            if( !FolderStack.empty() ) 
            { 
				TCHAR szCurText[MAX_PATH] = {0};
				m_wndCatalog.GetItemText(htiParent, szCurText, _countof(szCurText));
				CString strTotal;
				strTotal.Format(TEXT("%s(%ld)"), szCurText, nStorageLength);
				m_wndCatalog.SetItemText(htiParent, strTotal);

				ptrRootStg  = FolderStack.top().pStg; 
                ptrEnum     = FolderStack.top().pEnum; 
                htiParent   = FolderStack.top().hParent; 
                FolderStack.pop(); 

                hResult = S_OK; 
            } 

            continue; 
        } 

        switch(StatStg.type) 
        { 
        case STGTY_STORAGE: // 是存储对象, "文件夹" 
            { 
//.........这里部分代码省略.........
开发者ID:moon-sky,项目名称:fishjam-template-library,代码行数:101,代码来源:ChildFrm.cpp



注:本文中的GetErrorString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ GetEvent函数代码示例发布时间:2022-05-30
下一篇:
C++ GetErrorStr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap