示例#1
0
bool Open(V4V_CONTEXT& ctx, domid_t partner, uint32_t port)
{
    ATLTRACE(__FUNCTION__ " Entry\n");

    DWORD error(0);
    DWORD bytes(0);

    OVERLAPPED ov = { 0 };
    ov.hEvent = ::CreateEvent(0, true, false, 0);

    ::memset(&ctx, 0, sizeof(V4V_CONTEXT));
    ctx.flags = V4V_FLAG_OVERLAPPED;

    ATLTRACE(__FUNCTION__ " V4vOpen\n");

    if (!V4vOpen(&ctx, RingSize, &ov))
    {
        error = ::GetLastError();
    }
    else
    {
        error = GetResult(ctx, &ov, bytes);
    }

    if (error)
    {
        ATLTRACE(__FUNCTION__ " V4vOpen Error:%d\n", error);
    }
    else
    {
        v4v_ring_id_t v4vid = { 0 };
        v4vid.addr.domain = V4V_DOMID_NONE;
        v4vid.addr.port = port;
        v4vid.partner = partner;

        ATLTRACE(__FUNCTION__ " V4vBind\n");

        if (!V4vBind(&ctx, &v4vid, &ov))
        {
            error = ::GetLastError();
        }
        else
        {
            error = GetResult(ctx, &ov, bytes);
        }

        if (error)
        {
            ATLTRACE(__FUNCTION__ " V4vBind Error:%d\n", error);
        }
    }

    ::CloseHandle(ov.hEvent);

    ATLTRACE(__FUNCTION__ " Exit Result:%d\n", error);
    return (0 == error);
}
/**
 * Lists all iam policies
 */
int main(int argc, char** argv)
{
    Aws::SDKOptions options;
    Aws::InitAPI(options);
    {
        Aws::IAM::IAMClient iam;
        Aws::IAM::Model::ListPoliciesRequest request;

        bool done = false;
        bool header = false;
        while (!done)
        {
            auto outcome = iam.ListPolicies(request);
            if (!outcome.IsSuccess())
            {
                std::cout << "Failed to list iam policies: " <<
                    outcome.GetError().GetMessage() << std::endl;
                break;
            }

            if (!header)
            {
                std::cout << std::left << std::setw(55) << "Name" <<
                    std::setw(30) << "ID" << std::setw(80) << "Arn" <<
                    std::setw(64) << "Description" << std::setw(12) <<
                    "CreateDate" << std::endl;
                header = true;
            }

            const auto &policies = outcome.GetResult().GetPolicies();
            for (const auto &policy : policies)
            {
                std::cout << std::left << std::setw(55) <<
                    policy.GetPolicyName() << std::setw(30) <<
                    policy.GetPolicyId() << std::setw(80) << policy.GetArn() <<
                    std::setw(64) << policy.GetDescription() << std::setw(12) <<
                    policy.GetCreateDate().ToGmtString(DATE_FORMAT) <<
                    std::endl;
            }

            if (outcome.GetResult().GetIsTruncated())
            {
                request.SetMarker(outcome.GetResult().GetMarker());
            }
            else
            {
                done = true;
            }
        }
    }
    Aws::ShutdownAPI(options);
    return 0;
}
示例#3
0
	void GraffitiTab::handleIterateFinished ()
	{
		auto recIterator = qobject_cast<RecIterator*> (sender ());
		recIterator->deleteLater ();

		const auto& files = recIterator->GetResult ();

		FilesWatcher_->AddFiles (files);
		FilesModel_->AddFiles (files);

		auto resolver = LMPProxy_->GetTagResolver ();
		auto worker = [resolver, files] () -> QList<MediaInfo>
		{
			QList<MediaInfo> infos;
			for (const auto& file : files)
				try
				{
					infos << resolver->ResolveInfo (file.absoluteFilePath ());
				}
				catch (const std::exception& e)
				{
					qWarning () << Q_FUNC_INFO
							<< e.what ();
				}
			return infos;
		};

		auto scanWatcher = new QFutureWatcher<QList<MediaInfo>> ();
		connect (scanWatcher,
				SIGNAL (finished ()),
				this,
				SLOT (handleScanFinished ()));
		scanWatcher->setProperty ("LMP/Graffiti/Filename", recIterator->property ("LMP/Graffiti/Filename"));
		scanWatcher->setFuture (QtConcurrent::run (std::function<QList<MediaInfo> ()> (worker)));
	}
void AllocateAndAssociateAddress(const Aws::String& instance_id)
{
    Aws::EC2::EC2Client ec2;

    Aws::EC2::Model::AllocateAddressRequest request;
    request.SetDomain(Aws::EC2::Model::DomainType::vpc);

    auto outcome = ec2.AllocateAddress(request);
    if(!outcome.IsSuccess()) {
        std::cout << "Failed to allocate elastic ip address:" <<
            outcome.GetError().GetMessage() << std::endl;
        return;
    }

    Aws::String allocation_id = outcome.GetResult().GetAllocationId();

    Aws::EC2::Model::AssociateAddressRequest associate_request;
    associate_request.SetInstanceId(instance_id);
    associate_request.SetAllocationId(allocation_id);

    auto associate_outcome = ec2.AssociateAddress(associate_request);
    if(!associate_outcome.IsSuccess()) {
        std::cout << "Failed to associate elastic ip address" << allocation_id
            << " with instance " << instance_id << ":" <<
            associate_outcome.GetError().GetMessage() << std::endl;
        return;
    }

    std::cout << "Successfully associated elastic ip address " << allocation_id
        << " with instance " << instance_id << std::endl;
}
示例#5
0
/// @brief 添加一个TestCase到一个TestSuite\n
/// TEST(TestICalc, ExceptionData)将测试所有异常的数据
TEST(TestICalc, ExceptionData)
{
    for (int i=0; i<8; i++)
    {
        EXPECT_EQ( ExceptionResult[i], GetResult(ExceptionData[i]) ) << "Error at index :" << i;
    }
}
示例#6
0
//-----------------------------------------------------------------------------
C_NStrOutf::operator nstring () const
{
	bool bFormat = false;
	nstring szResult;
	nstring szFormat;
	std::vector<nstring>::size_type Pos = 0;

	for(const nstring::value_type &Itor : m_szFormat)
	{
		if(Itor == __T('{'))
		{
			bFormat = true;

			continue;
		}//if

		if(Itor == __T('}'))
		{
			bFormat = false;
			szResult += GetResult(szFormat, m_Data.size() > Pos ? m_Data[Pos] : __T(''));
			szFormat.clear();
			++Pos;

			continue;
		}//if

		if(bFormat)
			szFormat += Itor;
		else
			szResult += Itor;
	}//for

	return szResult;
}
示例#7
0
/// @brief 添加一个TestCase到一个TestSuite\n
/// TEST(TestICalc, NormalData)将测试所有正常的数据
TEST(TestICalc, NormalData)
{
    for (int i=0; i<42; i++)
    {
        EXPECT_EQ( NormalResult[i], GetResult(NormalData[i]) ) << "Error at index :" << i;
    }
}
示例#8
0
bool ResourceShader::Load( ResourceMemoryAllocator &inAllocator, ResourceDirectory &inDir ) {
    allocator = &inAllocator;

    auto res = ResourceDirectory::instance->Open(GetLocation(), ResourceDirectory::PERMISSION_ReadOnly);
    auto resIo = res.GetResult();

    if(!resIo) return false;

    Int size = 0;
    Int realSize = 0;
    Int bytesRead;

    const Int increment = 1024;
    do {
        size += increment;
        string = (char*)allocator->Reallocate(string, size+1);
        
        bytesRead = resIo->Read(string+size-increment, increment).GetResult();
        realSize += bytesRead;

        if(bytesRead < increment) break;
    } while(true);

    string = (char*)allocator->Reallocate(string, realSize+1);
    string[realSize] = 0;

    return true;
}
void MakeCallback(uv_work_t* req) {
  Nan::HandleScope scope;

  Nan::TryCatch try_catch;
  sass_context_wrapper* ctx_w = static_cast<sass_context_wrapper*>(req->data);
  struct Sass_Context* ctx;

  if (ctx_w->dctx) {
    ctx = sass_data_context_get_context(ctx_w->dctx);
  }
  else {
    ctx = sass_file_context_get_context(ctx_w->fctx);
  }

  int status = GetResult(ctx_w, ctx);

  if (status == 0 && ctx_w->success_callback) {
    // if no error, do callback(null, result)
    ctx_w->success_callback->Call(0, 0);
  }
  else if (ctx_w->error_callback) {
    // if error, do callback(error)
    const char* err = sass_context_get_error_json(ctx);
    v8::Local<v8::Value> argv[] = {
      Nan::New<v8::String>(err).ToLocalChecked()
    };
    ctx_w->error_callback->Call(1, argv);
  }
  if (try_catch.HasCaught()) {
    Nan::FatalException(try_catch);
  }

  sass_free_context_wrapper(ctx_w);
}
	void ExecuteCommandDialog::handleCurrentChanged (int id)
	{
		if (!dynamic_cast<WaitPage*> (currentPage ()))
			return;

		const auto& ids = pageIds ();

		const int pos = ids.indexOf (id);
		if (pos <= 0)
			return;

		const auto prevPage = page (ids.at (pos - 1));
		if (dynamic_cast<CommandsListPage*> (prevPage))
		{
			const AdHocCommand& cmd = dynamic_cast<CommandsListPage*> (prevPage)->GetSelectedCommand ();
			if (cmd.GetName ().isEmpty ())
				deleteLater ();
			else
				ExecuteCommand (cmd);
		}
		else if (dynamic_cast<CommandResultPage*> (prevPage))
		{
			const auto crp = dynamic_cast<CommandResultPage*> (prevPage);
			const auto& action = crp->GetSelectedAction ();
			if (action.isEmpty ())
				return;

			auto result = crp->GetResult ();
			result.SetDataForm (crp->GetForm ());
			ProceedExecuting (result, action);
		}
	}
示例#11
0
void SetPyException(const std::exception& ex)
{
    const char* message = ex.what();
    if (dynamic_cast<const MI::TypeConversionException*>(&ex))
    {
        PyErr_SetString(PyExc_TypeError, message);
    }
    else
    {
        PyObject* d = PyDict_New();
        PyObject* pyEx = nullptr;
        if (dynamic_cast<const MI::MITimeoutException*>(&ex))
        {
            pyEx = PyMITimeoutError;
        }
        else
        {
            pyEx = PyMIError;
        }

        if (dynamic_cast<const MI::MIException*>(&ex))
        {
            auto miex = static_cast<const MI::MIException*>(&ex);
            PyDict_SetItemString(d, "error_code", PyLong_FromUnsignedLong(miex->GetErrorCode()));
            PyDict_SetItemString(d, "mi_result", PyLong_FromUnsignedLong(miex->GetResult()));
        }

        PyDict_SetItemString(d, "message", PyUnicode_FromString(message));
        PyErr_SetObject(pyEx, d);
        Py_DECREF(d);
    }
}
示例#12
0
void rangeObject(ClientPtrType client, String bucketName, String key, String path, size_t min, size_t max)
{
    String base = "=== Range Object [" + bucketName + "/" + key;
    std::cout << base << "]: Start ===\n";
    std::cout << "Reading from " << path << "\n";
    String range(("byte=" + std::to_string(min) + "-" + std::to_string(max)).c_str());
    auto inpData = Aws::MakeShared<Aws::FStream>("GetObjectInputStream",
            path.c_str(), std::ios_base::in | std::ios_base::binary);
    auto objReq = Aws::S3::Model::GetObjectRequest();
    objReq.WithBucket(bucketName).WithKey(key).WithRange(range);
    auto objRes = client->GetObject(objReq);
    if (!objRes.IsSuccess())
    {
        std::cout << base << "]: Client Side failure ===\n";
        std::cout << objRes.GetError().GetExceptionName() << "\t" <<
                     objRes.GetError().GetMessage() << "\n";
        std::cout << base << "]: Failed ===\n";
    }
    else
    {
        Aws::IOStream& file = objRes.GetResult().GetBody();
        if (!doFilesMatch(inpData.get(), file, min, max))
        {
            std::cout << base << "]: Content not equal ===\n";
        }
    }
    std::cout << base << "]: End ===\n\n";
}
示例#13
0
void CExampleTest::TestCase02()
{
	char *input[] = {"10 10 10 10 10 10 9 xiaoyuanwang","0 0 0 0 0 0 0 beast"};
	char result[100] = {0};
	GetResult(input, 2, result);
	CPPUNIT_ASSERT(0 == strcmp(result, "xiaoyuanwang 10.00\nbeast 0.00") );
}
示例#14
0
int main()
{
	char input[20] = {0};
	int len = 0;
	int res = 0;
	int i = 0;
	int j = 0;
	ElementType infix[20] = {0};
	ElementType suffix[20] = {0};
	
	//StackNode* infix_head;
	//StackNode* top;
	
	fgets(input,20,stdin);
	len = ArrayToInfix(input,infix);
	//PrintFormula(infix, len);
	len = InfixToSuffix(infix,suffix,len);
	//PrintFormula(suffix, len);
	res = GetResult(suffix,len);
	printf("= %d\n", res);
	//PrintInfix(infix,len);
	/*InitStack(&infix_head, &top);
	for (i = 0; i < len; ++i)
	{
		StackPush(infix_head,&top,infix[i]);
	}
	PrintStack(infix_head);*/
	
}
示例#15
0
// Виконааня команди cmd з параметрами params
int XLibraLP::DoCmd(unsigned char cmd, char *params)
{
    SendLibraNum();

    Write(&cmd, 1);

    switch (cmd)
    {
        case 0x82:
            Write(params, 83);
         break;
        case 0x8a:
            Write(params, 9);
         break;
        case 0x8d:
            Write(params, 4);
         break;
        case 0x81:
            Write(params, 4);
            unsigned char ch;
            for (int i(0); i < 100; i++)
                Read(&ch, 1);
         break;
    };

    Listen();

    return GetResult()->error;
}
示例#16
0
/****************************************************************
** 功    能:应答报文组包
** 输入参数:
**        ptApp                 app结构指针
** 输出参数:
**        szRspBuf              交易应答报文
** 返 回 值:
**        >0                    报文长度
**        FAIL                  失败
** 作    者:
**        fengwei
** 日    期:
**        2012/12/18
** 调用说明:
**
** 修改日志:
****************************************************************/
int PackWebRsp(T_App *ptApp, char *szRspBuf)
{
    int     iIndex;                 /* buf索引 */
    int     iMsgCount;              /* 短信记录数 */
    int     iRetDescLen;            /* 响应信息长度 */

    iIndex = 0;

    /* 交易代码 */
    memcpy(szRspBuf+iIndex, ptApp->szTransCode, 8);
    iIndex += 8;

    /* 响应码 */
    memcpy(szRspBuf+iIndex, ptApp->szRetCode, 2);
    iIndex += 2;

    /* 根据返回码取返回信息 */
	if(strlen(ptApp->szRetDesc) == 0)
	{
		GetResult(ptApp->szRetCode, ptApp->szRetDesc);
	}

    /* 响应信息长度 */
    iRetDescLen = strlen(ptApp->szRetDesc);
    szRspBuf[iIndex] = iRetDescLen;
    iIndex += 1;

    /* 响应信息 */
	memcpy(szRspBuf+iIndex, ptApp->szRetDesc, iRetDescLen);
    iIndex += iRetDescLen;

    return iIndex;
}
示例#17
0
BOOL CMatrixDoc::ProcOneString(const CString & sData)
{
	CString temp=sData;
	CString sName=_T("");
	bool IsExisted=false;
	CArrayMatrix *PtrNew=NULL;
	if(!CArrayMatrix::SetStringName(temp,sName)) return FALSE;
	CArrayMatrix::ProcString(temp);
	POSITION pos=m_VariablePtrList.GetHeadPosition();
	for(int i=0;i<m_VariablePtrList.GetCount();i++)
	{
		CArrayMatrix *Ptr=(CArrayMatrix *)m_VariablePtrList.GetAt(pos);
		if(Ptr->GetName()==sName) {IsExisted=true;PtrNew=Ptr;break;}
		m_VariablePtrList.GetNext(pos);
	}
	if(!IsExisted)
	{
		PtrNew=new CArrayMatrix;
		pos=m_VariablePtrList.AddTail(PtrNew);
	}
	//现在PtrNew指向新的目标变量
	CArrayMatrix tpMatrix;
	if(!GetResult(temp,tpMatrix))
	{
		if(!IsExisted)
		{
			delete PtrNew;
			m_VariablePtrList.RemoveAt(pos);
			return FALSE;
		}
	}
	*PtrNew=tpMatrix;
	return true;
}
示例#18
0
void CWndToolbox::DoModal()
{
	BIOS::SYS::Beep(100);
	/*
#ifdef _WIN32
	// no enough ram for this on ARM M3 :(
	ui16 buffer[Width*Height];
	BIOS::LCD::GetImage( m_rcClient, buffer );
#endif
	*/
	m_bRunning = true;
	m_bFirst = true;
	m_bAdcEnabled = BIOS::ADC::Enabled();
	BIOS::ADC::Enable(false);

	if ( MainWnd.m_wndMenuInput.m_wndListTrigger.IsVisible() )
		MainWnd.m_wndMenuInput.m_wndListTrigger.Invalidate();
	if ( MainWnd.m_wndMenuInput.m_itmTrig.IsVisible() )
		MainWnd.m_wndMenuInput.m_itmTrig.Invalidate();

	CWnd* pSafeFocus = GetFocus();
	SetFocus();
	ShowWindow( CWnd::SwShow );
	Invalidate();
	while ( IsRunning() )
	{
		Sleep(20);
	}
	ShowWindow( CWnd::SwHide );
	/*
#ifdef _WIN32
	BIOS::LCD::PutImage( m_rcClient, buffer );
#endif*/

	switch ( GetResult() )
	{
	case MenuPauseResume: 
		// Resume / Pause
		m_bAdcEnabled = !m_bAdcEnabled;
		break;
	case MenuManager:
		m_bAdcEnabled = FALSE;
		// Load wave BIN
		break;
	case MenuReset:
		Settings.Reset();
		break;
	case -1: break;
	}

	UpdateAdc();

	pSafeFocus->SetFocus();

	CRect rcSafe = m_rcOverlay;
	m_rcOverlay.Invalidate();
	MainWnd.Invalidate(); // to redraw the graph
	m_rcOverlay = rcSafe;
}
示例#19
0
void Report::Flush()
{
	if(pagei >= 0) {
		Drawing dw = GetResult();
		page.At(pagei).Append(dw);
		Create(GetSize());
	}
}
示例#20
0
std::string FootballMatch::GetLoser() const
{
	Result res = GetResult();
	if (res.home < res.guest)
		return m_homeTeam;
		
	return m_guestTeam;
}
//프로그램의 전체적 흐름.
int main(void)
{
	int nResult = 0;

	nResult = GetResult();
	printf("당신의 학점은 '%c'(%d)입니다.\n", GetGrade(nResult), nResult);
	return 0;
}
示例#22
0
文件: jfqdlg.cpp 项目: jimodb/codes
QJfqDlg::QJfqDlg(QWidget *parent){
	ui=new Ui_JFQDlg();
	ui->setupUi(this);
	this->setVisible(true);
	
	connect(ui->btnEqual,SIGNAL(clicked()),
					this,SLOT(GetResult()));
}
示例#23
0
std::string BasketballMatch::GetWinner() const
{
	Result res = GetResult();
	if (res.home > res.guest)
		return m_homeTeam;
		
	return m_guestTeam;
}
示例#24
0
文件: Util.cpp 项目: pedia/raidget
void DrawingPageDraw__::Flush()
{
	if(pagei >= 0) {
		Drawing dw = GetResult();
		page.At(pagei).Append(dw);
		Create(size);
	}
}
示例#25
0
  void OnSuccess()
  {
    // Find out who took damage, display in HUD
    // TODO
std::cout << GetResult().GetString() << "\n";

    m_opponent->ShowAttacked();
    CheckCollects();
  }
NS_IMETHODIMP
nsIDBDatabaseException::GetCode(PRUint16* aCode)
{
  NS_ASSERTION(aCode, "Null pointer!");
  nsresult result;
  GetResult(&result);
  *aCode = NS_ERROR_GET_CODE(result);
  return NS_OK;
}
示例#27
0
SmplMatrixDialog::~SmplMatrixDialog()
{
	if (GetResult())									// exit dialog with "OK"?
	{
		preview.FinishDocumentUpdate();	// wait until the effect has been applied
		BfpSetDocumentPreviewFlag(document_preview);
		BfpSetTextureModeFlag(settings->tile_flags == TILE_REPEAT_TILING);
	}
}
示例#28
0
void nuiDialogSelectFile::OnDialogDone(const nuiEvent& rEvent)
{
  nuiDialog::DialogResult result = GetResult();
  
  if (result == nuiDialog::eDialogAccepted)
  {
    OnSelectorOK(rEvent);
    rEvent.Cancel();
  }
}
示例#29
0
文件: snake.c 项目: dylqt/huawei
int main() 
{
	int Num = 0;
	scanf("%d", &Num);
	int sum_Num = (Num + 1) * Num / 2;
	int *pResult = (int *)calloc(sum_Num, sizeof(int));
	GetResult(Num, pResult);
	free(pResult);
	return 0;
}
NS_IMETHODIMP
nsDOMFileException::GetCode(PRUint16* aCode)
{
  NS_ENSURE_ARG_POINTER(aCode);
  nsresult result;
  GetResult(&result);
  *aCode = NS_ERROR_GET_CODE(result);

  return NS_OK;
}