Esempio n. 1
0
int main(int argc, const char **argv)
{
    sIndicationProxy = new PhysMemMasterIndicationProxy(IfcNames_PhysMemMasterIndication, &transportSocketResp, NULL);
    PhysMemMasterRequest sRequest(IfcNames_PhysMemMasterRequest, &transportSocketResp, NULL);

    printf("[%s:%d] daemon sleeping...\n", __FUNCTION__, __LINE__);
    while(1)
        sleep(100);
    return 0;
}
Esempio n. 2
0
MCResult 
MemCacheClient::IncDec(
    const char *    aType, 
    unsigned        aService,
    const char *    aKey, 
    uint64_t *      aNewValue,
    uint64_t        aDiff,
    bool            aWantReply
    )
{
    string_t key(aKey);
    Server * pServer = FindServer(key, aService);
    if (!pServer) return MCERR_NOSERVER;

    char szBuf[50];
    string_t sRequest(aType);
    sRequest += ' ';
    sRequest += aKey;
    snprintf(szBuf, sizeof(szBuf), " %" PRIu64, aDiff);
    sRequest += szBuf;
    if (!aWantReply) {
        sRequest += " noreply";
    }
    sRequest += "\r\n";

    try {
        pServer->SendBytes(sRequest.data(), sRequest.length());

        if (!aWantReply) {
            return MCERR_NOREPLY;
        }

        string_t sValue;
        sValue = pServer->GetByte();
        while (sValue[sValue.length()-1] != '\n') {
            sValue += pServer->GetByte();
        }

        if (sValue == "NOT_FOUND\r\n") {
            return MCERR_NOTFOUND;
        }

        if (aNewValue) {
            *aNewValue = strtoull(sValue.data(), NULL, 10);
        }
        return MCERR_OK;
    }
    catch (const Socket::Exception & e) {
        mTrace.Trace(CLINFO, "IncDec: error '%s' at %s, marking request as NOSERVER",
            e.mDetail, pServer->GetAddress());
        pServer->Disconnect();
        return MCERR_NOSERVER;
    }
}
Esempio n. 3
0
registrationKeyDialog::registrationKeyDialog(QWidget* parent, const char* name, bool modal, Qt::WindowFlags fl)
  : QDialog(parent, modal ? (fl | Qt::Dialog) : fl)
{
  setObjectName(name);
  setupUi(this);

  connect(_key, SIGNAL(textChanged(const QString&)), this, SLOT(sCheckKey()));
  connect(_close,   SIGNAL(clicked()), this, SLOT(reject()));
  connect(_request, SIGNAL(clicked()), this, SLOT(sRequest()));
  connect(_select,  SIGNAL(clicked()), this, SLOT(sSelect()));
}
Esempio n. 4
0
MCResult 
MemCacheClient::IncDec(
    const char *    a_pszType, 
    const char *    a_pszKey, 
    uint64_t *      a_pnNewValue,
    uint64_t        a_nDiff,
    bool            a_bWantReply
    )
{
    Server * pServer = FindServer(a_pszKey);
    if (!pServer) return MCERR_NOSERVER;

    char szBuf[50];
    string_t sRequest(a_pszType);
    sRequest += ' ';
    sRequest += a_pszKey;
    snprintf(szBuf, sizeof(szBuf), " " SPRINTF_UINT64, a_nDiff);
    sRequest += szBuf;
    if (!a_bWantReply) {
        sRequest += " noreply";
    }
    sRequest += "\r\n";

    try {
        pServer->SendBytes(sRequest.data(), sRequest.length());

        if (!a_bWantReply) {
            return MCERR_NOREPLY;
        }

        string_t sValue;
        sValue = pServer->GetByte();
        while (sValue[sValue.length()-1] != '\n') {
            sValue += pServer->GetByte();
        }

        if (sValue == "NOT_FOUND\r\n") {
            return MCERR_NOTFOUND;
        }

        if (a_pnNewValue) {
            *a_pnNewValue = STRTOUL64(sValue.data(), NULL, 10);
        }
        return MCERR_OK;
    }
    catch (const ServerSocket::Exception &) {
        pServer->Disconnect();
        return MCERR_NOSERVER;
    }
}
Esempio n. 5
0
int main(int argc, const char **argv)
{

    sIndicationProxy = new EchoIndicationProxy(IfcNames_EchoIndicationH2S, &transportSocketResp, NULL);
    sIndicationProxy2 = new EchoIndicationProxy(IfcNames_EchoIndication2H2S, &transportSocketResp, NULL);
    EchoRequest sRequest(IfcNames_EchoRequestS2H, &transportSocketResp, NULL);
    EchoRequest sRequest2(IfcNames_EchoRequest2S2H, &transportSocketResp, NULL);
    EchoIndication echoIndication(IfcNames_EchoIndicationH2S, NULL, NULL);
    echoRequestProxy = new EchoRequestProxy(IfcNames_EchoRequestS2H);

    printf("[%s:%d] daemon sleeping...\n", __FUNCTION__, __LINE__);
    while(1)
        sleep(100);
    return 0;
}
Esempio n. 6
0
int main(int argc, const char **argv)
{
    PortalSocketParam paramSocket = {};
    PortalMuxParam param = {};

    EchoIndication echoIndication(IfcNames_EchoIndicationH2S, NULL, NULL);
    echoRequestProxy = new EchoRequestProxy(IfcNames_EchoRequestS2H);

    Portal *mcommon = new Portal(0, 0, sizeof(uint32_t), portal_mux_handler, NULL, &transportSocketResp, &paramSocket, 0);
    param.pint = &mcommon->pint;
    sIndicationProxy = new EchoIndicationSWProxy(IfcNames_EchoIndicationH2S, &transportMux, &param);
    EchoRequest sRequest(IfcNames_EchoRequestS2H, &transportMux, &param);

    sSecondIndicationProxy = new SecondIndicationProxy(IfcNames_SecondIndication, &transportMux, &param);
    SecondRequest sSecondRequest(IfcNames_SecondRequest, &transportMux, &param);

    sThirdIndicationProxy = new ThirdIndicationProxy(IfcNames_ThirdIndication, &transportMux, &param);
    ThirdRequest sThirdRequest(IfcNames_ThirdRequest, &transportMux, &param);

    printf("[%s:%d] daemon sleeping...\n", __FUNCTION__, __LINE__);
    while(1)
        sleep(100);
    return 0;
}
Esempio n. 7
0
//---------------------------------------------------------
bool CWMS_Import::Get_Map(wxHTTP *pServer, const CSG_String &Directory, CWMS_Capabilities &Cap)
{
	bool	bResult	= false;

	int				i, n;
	CSG_Rect		r(Cap.m_Extent);
	CSG_Parameters	p;

	//-----------------------------------------------------
//	if( Cap.m_MaxWidth  > 2 && NX > Cap.m_MaxWidth  )	NX	= Cap.m_MaxWidth;
//	if( Cap.m_MaxHeight > 2 && NY > Cap.m_MaxHeight )	NY	= Cap.m_MaxHeight;

	p.Add_Range	(NULL	, "X_RANGE"	, _TL("X Range")	, _TL(""), r.Get_XMin(), r.Get_XMax(), r.Get_XMin(), r.Get_XRange() > 0.0, r.Get_XMax(), r.Get_XRange() > 0.0);
	p.Add_Range	(NULL	, "Y_RANGE"	, _TL("Y Range")	, _TL(""), r.Get_YMin(), r.Get_YMax(), r.Get_YMin(), r.Get_YRange() > 0.0, r.Get_YMax(), r.Get_YRange() > 0.0);

	p.Add_Value	(NULL	, "CELLSIZE", _TL("Cellsize")	, _TL(""), PARAMETER_TYPE_Double, r.Get_XRange() / 2001.0, 0.0, true);

	p.Add_Choice(NULL	, "FORMAT"	, _TL("Format")		, _TL(""), Cap.m_Formats);
	p.Add_Choice(NULL	, "PROJ"	, _TL("Projections"), _TL(""), Cap.m_Projections);

	CSG_Parameter	*pNode	= p("FORMAT");
	for(i=0; i<pNode->asChoice()->Get_Count(); i++)
	{
		CSG_String	s(pNode->asChoice()->Get_Item(i));
		if( !s.CmpNoCase(SG_T("image/png")) )
			pNode->Set_Value(i);
	}

	for(i=0; i<Cap.m_Layers_Name.Get_Count(); i++)
	{
		p.Add_Value(NULL, Cap.m_Layers_Name[i], Cap.m_Layers_Title[i], "", PARAMETER_TYPE_Bool, false);
	}

	//-----------------------------------------------------
	if( pServer && Dlg_Parameters(&p, _TL("WMS Import")) )
	{
		int			NX, NY;
		double		Cellsize;
		CSG_String	Layers, Format;

		//-------------------------------------------------
		r.Assign(
			p("X_RANGE")->asRange()->Get_LoVal(),
			p("Y_RANGE")->asRange()->Get_LoVal(),
			p("X_RANGE")->asRange()->Get_HiVal(),
			p("Y_RANGE")->asRange()->Get_HiVal()
		);

		Cellsize	= p("CELLSIZE")	->asDouble();

		NX			= 1 + (int)(r.Get_XRange() / Cellsize);
		NY			= 1 + (int)(r.Get_YRange() / Cellsize);

		//-------------------------------------------------
		Layers.Clear();

		for(i=0, n=0; i<Cap.m_Layers_Name.Get_Count(); i++)
		{
			if( p(Cap.m_Layers_Name[i])->asBool() )
			{
				if( n++ > 0 )	Layers	+= ",";

				Layers	+= Cap.m_Layers_Name[i];
			}
		}

		if( n == 0 )
		{
			return( false );
		}

		//-------------------------------------------------
		wxBitmapType	tFormat;

		Format	= p("FORMAT")->asString();

		if(      Format.Contains(SG_T("image/gif" )) )	tFormat	= wxBITMAP_TYPE_GIF ;
		else if( Format.Contains(SG_T("image/jpeg")) )	tFormat	= wxBITMAP_TYPE_JPEG;
		else if( Format.Contains(SG_T("image/png" )) )	tFormat	= wxBITMAP_TYPE_PNG ;
		else if( Format.Contains(SG_T("image/wbmp")) )	tFormat	= wxBITMAP_TYPE_BMP ;
		else if( Format.Contains(SG_T("image/bmp" )) )	tFormat	= wxBITMAP_TYPE_BMP ;
		else if( Format.Contains(SG_T("image/tiff")) )	tFormat	= wxBITMAP_TYPE_TIF ;
		else if( Format.Contains(SG_T("GIF"       )) )	tFormat	= wxBITMAP_TYPE_GIF ;
		else if( Format.Contains(SG_T("JPEG"      )) )	tFormat	= wxBITMAP_TYPE_JPEG;
		else if( Format.Contains(SG_T("PNG"       )) )	tFormat	= wxBITMAP_TYPE_PNG ;
		else
		{
			return( false );
		}

		//-------------------------------------------------
		CSG_String	sRequest(Directory);

		sRequest	+= SG_T("?SERVICE=WMS");
		sRequest	+= SG_T("&VERSION=")	+ Cap.m_Version;
		sRequest	+= SG_T("&REQUEST=GetMap");

		sRequest	+= SG_T("&LAYERS=")		+ Layers;

		if( Cap.m_Projections.Length() > 0 )
			sRequest	+= CSG_String(S_SRS(Cap.m_Version)) + p("PROJ")->asString();

		sRequest	+= SG_T("&FORMAT=")		+ Format;

		sRequest	+= CSG_String::Format(SG_T("&WIDTH=%d&HEIGHT=%d"), NX, NY);
		sRequest	+= CSG_String::Format(SG_T("&BBOX=%f,%f,%f,%f"), r.m_rect.xMin, r.m_rect.yMin, r.m_rect.xMax, r.m_rect.yMax);

		Message_Add(sRequest, true);

		//-------------------------------------------------
		wxInputStream	*pStream;

		if( (pStream = pServer->GetInputStream(sRequest.c_str())) == NULL )
		{
			Message_Add(_TL("could not open GetMap stream"));
		}
		else
		{
			wxImage	Image;

			if( Image.LoadFile(*pStream, tFormat) == false )
			{
				Message_Add(_TL("could not read image"));

				CSG_String	s	= SG_T("\n");

				pStream->SeekI(0, wxFromStart);

				while( !pStream->Eof() )
				{
					s	+= (char)pStream->GetC();
				}

				Message_Add(s);
			}
			else
			{
				CSG_Grid	*pGrid	= SG_Create_Grid(SG_DATATYPE_Int, Image.GetWidth(), Image.GetHeight(), Cellsize, r.m_rect.xMin, r.m_rect.yMin);

				for(int y=0, yy=pGrid->Get_NY()-1; y<pGrid->Get_NY() && Set_Progress(y, pGrid->Get_NY()); y++, yy--)
				{
					for(int x=0; x<pGrid->Get_NX(); x++)
					{
						pGrid->Set_Value(x, y, SG_GET_RGB(Image.GetRed(x, yy), Image.GetGreen(x, yy), Image.GetBlue(x, yy)));
					}
				}

				//-----------------------------------------
				pGrid->Set_Name(Cap.m_Title);
				Parameters("MAP")->Set_Value(pGrid);
				DataObject_Set_Colors(pGrid, 100, SG_COLORS_BLACK_WHITE);

				CSG_Parameters	Parms;

				if( DataObject_Get_Parameters(pGrid, Parms) && Parms("COLORS_TYPE") )
				{
					Parms("COLORS_TYPE")->Set_Value(3);	// Color Classification Type: RGB

					DataObject_Set_Parameters(pGrid, Parms);
				}

				bResult	= true;
			}

			delete(pStream);
		}
	}

	return( bResult );
}
Esempio n. 8
0
int RtspRequest::ParseRtspPackage(char Buf[], int Size) //bool bReq
{
    int ret = 0;
    StringArray_t saLine;
    StringPair_t spHeader;
    string Delim=CRLF;
    string sRequest(Buf, Size);
    U32 theHeader = 0;
    StringUtil::Trim(sRequest);
    StringUtil::Split(sRequest, Delim, saLine);
    //Request Line
    
    if(strncmp(saLine[0].c_str(), RTSPProtocol::GetVersionString(RTSPProtocol::k10Version).Ptr, RTSPProtocol::GetVersionString(RTSPProtocol::k10Version).Len) != 0) //bReq
    {    
        m_bIsRequest = true;
        ret = ParseRequestLine(saLine[0]);
        if(ret < 0)
        {
            return -1;
        }
    }
    else
    {
        m_bIsRequest = false;
        ret = ParseStatusLine(saLine[0]);
        if(ret < 0)
        {
            return -1;
        }    
    }
    //Parse Header
    for(int i=1; i<saLine.size(); i++)
    {           
        StringUtil::Split(saLine[i], ':', spHeader);
        theHeader = RTSPProtocol::GetRequestHeader(StrPtrLen((char*)spHeader.first.c_str()));
        if(qtssIllegalHeader != theHeader)
        {
            StringUtil::Trim(spHeader.second);
            m_HeaderDict[theHeader] = spHeader.second;
        }

        //some headers require some special processing. If this code begins
        //to get out of control, we made need to come up with a function pointer table
        switch (theHeader)
        {
            case qtssSessionHeader:             ParseSessionHeader(); break;
            case qtssCSeqHeader:                ParseCSeqHeader(); break;
            case qtssTransportHeader:           ParseTransportHeader(); break;
            case qtssRangeHeader:               ParseRangeHeader();     break;
            case qtssContentLengthHeader:       ParseContentLengthHeader();break;
            case qtssSpeedHeader:               ParseSpeedHeader();     break;
            case qtssScaleHeader:               ParseScaleHeader();     break;
            case qtssRequireHeader:             ParseRequireHeader();   break;
            case ngodNoticeHeader:              ParseNoticeHeader();    break;
            case ngodOnDemandSessionIdHeader:   ParseOnDemandSessionIdHeader(); break;
            case ngodReasonHeader:              ParseReasonHeader(); break;
            case ngodSessionGroupHeader:        ParseSessionGroupHeader(); break;
            default:    break;
        }

    }
    return 0;
}