Beispiel #1
0
MsgPacket* MsgConnection::TransmitMessage(MsgPacket* message) {
	if(!SendRequest(message)) {
		return NULL;
	}

	return ReadResponse();
}
Beispiel #2
0
static void
Reader( cOpenHpiClientConf *c )
{
  // create pollfd
  struct pollfd pfd;

  pfd.events = POLLIN;

  // reader loop
  while( !c->m_thread_exit )
     {
       assert( c->m_client_connection->m_fd >= 0 );
       pfd.fd = c->m_client_connection->m_fd;

       int rv = poll( &pfd, 1, 100 );

       if ( rv == 1 )
            // read response
            ReadResponse( c );
       else if ( rv != 0 )
          {
            if ( errno != EINTR )
               {
                 // error
                 assert( 0 );
                 abort();
               }
          }

       // check for expiered ipmi commands
       struct timeval now;
       gettimeofday( &now, 0 );

       Lock( c );

       int i;
       for( i = 0; i < 256; i++ )
          {
            if ( c->m_outstanding[i] == 0 )
                 continue;

            cOpenHpiClientRequest *r = c->m_outstanding[i];

            if (    r->m_timeout.tv_sec > now.tv_sec 
		 || (    r->m_timeout.tv_sec == now.tv_sec
		      && r->m_timeout.tv_usec > now.tv_usec ) )
                 continue;

            // timeout expired
            RemOutstanding( c, r->m_seq );

            HandleMsgError( c, r, SA_ERR_HPI_TIMEOUT );
          }

       // send new comands
       SendCmds( c );

       Unlock( c );
     }
}
Beispiel #3
0
int RoboFocus::updateRFPosition(double *value)
{
    float temp ;
    char rf_cmd[RF_MAX_CMD] ;
    int robofocus_rc ;

    DEBUG(INDI::Logger::DBG_DEBUG, "Querying Position...");

    if (isSimulation())
    {
        *value = simulatedPosition;
        return 0;
    }

    strcpy(rf_cmd, "FG000000" ) ;

    if ((robofocus_rc= SendCommand(rf_cmd)) < 0)
        return robofocus_rc;

    if ((robofocus_rc= ReadResponse(rf_cmd)) < 0)
        return robofocus_rc;

    if (sscanf(rf_cmd, "FD%6f", &temp) < 1)
        return -1;

    *value = (double) temp;

    DEBUGF(INDI::Logger::DBG_DEBUG, "Position: %g", *value);

    return 0;

}
Beispiel #4
0
int RoboFocus::updateRFTemperature(double *value)
{
    DEBUGF(INDI::Logger::DBG_DEBUG, "Update Temperature: %g", value);

    float temp ;
    char rf_cmd[32] ;
    int robofocus_rc ;

    strcpy(rf_cmd, "FT000000" ) ;

    if ((robofocus_rc= SendCommand( rf_cmd)) < 0)
        return robofocus_rc;

    if (isSimulation())
        snprintf(rf_cmd, 32, "FT%6g", simulatedTemperature);
    else  if ((robofocus_rc= ReadResponse(rf_cmd)) < 0)
            return robofocus_rc;

    if (sscanf(rf_cmd, "FT%6f", &temp) < 1)
        return -1;

    *value = (double) temp/2.- 273.15;

    return 0;
}
Beispiel #5
0
bool Client::GetPostResult(Value& result)
{
    log_trace();
    gettimeofday( &startTime_, 0 );
    result.SetInvalid();

    if (responseProcessed_)
    {
        PreserveReceiveBuffer();
        ResetTransaction();
    }

    if (socket_.IsConnected(0) &&
        ReadHeader(result) &&
        ReadResponse(result))
    {
        switch (ProcessResponse(result))
        {
            case ProcessResponseSuccess       : return true;
            case ProcessResponseErrorKeepOpen : return false;
        }
    }

    Reset();
    return false;
}
Beispiel #6
0
bool MsgConnection::TransmitMessage(MsgPacket* request, MsgPacket* response) {
	if(!SendRequest(request)) {
		return false;
	}

	return ReadResponse(response);
}
Beispiel #7
0
void XaLanguage::Read() {

	vector<string> FieldsToRead = XaLibModel::ReadPrepare({"XaLanguage"},"/XaLanguage/fieldset/field");
	
	DbResMap DbRes=XaLibSql::Select(DB_READ,"XaLanguage",FieldsToRead,{"id"},{HTTP.GetHttpParam("id")});
	RESPONSE.Content= ReadResponse(DbRes,FieldsToRead);
};
Beispiel #8
0
bool Printer::Idle( void ) {
    string str;
    bool is_connected;

    while ( ( str = ReadResponse() ) != "" )
        ParseResponse( str );

    if ( m_view ) {
        while ( ( str = ReadLog() ) != "" )
            m_view->comm_log( str );

        while ( ( str = ReadErrorLog() ) != "" ) {
            alert( str.c_str() );
        }
    }

    if ( ( is_connected = IsConnected() ) != was_connected ) {
        was_connected = is_connected;
        signal_serial_state_changed.emit( is_connected ? SERIAL_CONNECTED : SERIAL_DISCONNECTED );
    }

    if ( waiting_temp && --temp_countdown == 0 &&
            m_model && m_model->settings.get_boolean("Misc","TempReadingEnabled") ) {
        UpdateTemperatureMonitor();
        temp_countdown = 100;
        waiting_temp = false;
    }

    return true;
}
Beispiel #9
0
INT PutFile(SOCKET sd, char *fileName)
{
	INT status;
	INT fileSize;

	/* Send the the request to the server on socket sd */
	printf("uploading %s...\n", fileName);
	strcpy_s(request.fileName, fileName);
	if ((fileSize=getFileSize(fileName)) == -1)  
		return IO_ERROR;
	_itoa_s(fileSize, request.fileSize, 10);
	strcpy_s(request.cmdName, PUT_FILE);
 
	if (!WriteRequest(sd, &request))  
		return IO_ERROR;
	 
		
	if ((status = uploadFile(fileName, sd, fileSize)) != STATUS_OK)
		return status;
	 
	if (!ReadResponse(sd, &response))
		return IO_ERROR;
	
	return  atoi(response.status);
	 
}
Beispiel #10
0
/**
 * @paragraph This method reads the socket response
 * @brief ServerPanel::ReadResponse
 * @return void
 */
void ServerPanel::ReadResponse() {
    // Create the data stream
    QDataStream qdsServerPanel(this->mClient);
    // Check the block size
    if (this->mBlockSize == 0) {
        // Make sure we have a valid amount of daya
        if (this->mClient->bytesAvailable() < (int) sizeof(quint16)) {
            // We're done
            return;
        }
        // Read the data
        qdsServerPanel >> this->mBlockSize;
    }
    // See if we have read all of the data
    if (this->mClient->bytesAvailable() < this->mBlockSize) {
        // We're done
        return;
    }
    // Set a response placeholder
    QString sJson;
    // Read the stream
    qdsServerPanel >> sJson;
    // Check for data
    if (sJson.isEmpty()) {
        // Rerun the read
        QTimer::singleShot(0, this, SLOT(ReadResponse()));
        // We're done
        return;
    }
    // Store the json into the system
    this->mJsonResponse = sJson;
    // Disconnect from the host
    this->mClient->disconnectFromHost();
}
Beispiel #11
0
QStringList TRedisClient::Query(QString cmd)
{
    QStringList response;
    if(SendRequest(cmd)) {
        response = ReadResponse();
    }
    return response;
}
Beispiel #12
0
BOOL CPop3Connection::ReadListResponse(int nNumberOfMails)
{
	//Must be connected to perform a "LIST"
	if(!m_bConnected)
	{
		//m_sLastCommandResponse = _T("ͨÐÅ佨Á¢");//<%IDS_Pop3_32%>
		m_sLastCommandResponse = ::FuncGetStringFromIDS("<%IDS_Pop3_32%>");//<%IDS_Pop3_32%>
		return FALSE;
	}
	
	//retrieve the reponse
	LPSTR pszOverFlowBuffer = NULL;
	int nSize = 14 * nNumberOfMails + 100;
	char* sBuf = new char[nSize];
	char* sMessageBuf = sBuf;
	if (!ReadResponse(sBuf, nSize, "\r\n.\r\n", &pszOverFlowBuffer))
	{
		delete [] sBuf;
		if (pszOverFlowBuffer)
			delete [] pszOverFlowBuffer;
		
		TRACE(_T("Error retrieving the LIST response from the POP3 server"));
		return FALSE;
	}
	if (pszOverFlowBuffer)
		sMessageBuf = pszOverFlowBuffer;
	
	//determine if the response is an error
	if (strnicmp(sMessageBuf,"+OK", 3) != 0)
	{
		delete [] sBuf;
		if (pszOverFlowBuffer)
			delete [] pszOverFlowBuffer;
		
		SetLastError(WSAEPROTONOSUPPORT);
		TRACE(_T("POP3 server did not respond correctly to the LIST response\n"));
		return FALSE;
	}
	else
	{  
		//Retrieve the message sizes and put them
		//into the m_msgSizes array
		m_msgSizes.RemoveAll();
		m_msgSizes.SetSize(0, nNumberOfMails);
		
		//then parse the LIST response
		char* pszSize = GetFirstCharInResponse(sMessageBuf);
		VERIFY(pszSize);
		for (; *pszSize != '.'; pszSize++)
			if (*pszSize == '\t' || *pszSize == ' ')
				m_msgSizes.Add(atoi(pszSize));
	}
	delete [] sBuf;
	if (pszOverFlowBuffer)
		delete [] pszOverFlowBuffer;
	
	return TRUE; 
}
Beispiel #13
0
void XaMediaData::Read(){

	string Id=HTTP.GetHttpParam("id");

	string XPathExpr="/XaMediaData/fieldset/field";
	vector<string> XmlFiles = {"XaMediaData"};


	//LOAD XML FOR MODEL
	xmlDocPtr XmlDomDoc=XaLibDom::DomFromFile(AddXmlFile(XmlFiles),0);

	//GET NUMBER OF FILEDS
	int FieldsNum=XaLibDom::GetNumRowByXPathInt(XmlDomDoc,XPathExpr);

	string QryFields="SELECT R.id";
	string QryJoin="";

	for (auto i=0;i<FieldsNum;i++) {

		string j=to_string(i+1);

		if (XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/read")=="yes") {

			if (XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/type")=="select-single-domain") {
				string FieldName=XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/name");
				QryFields+=",X"+j+".name AS "+FieldName;
				QryJoin+=" LEFT JOIN XaDomain X"+j+" ON X"+j+".id=R."+FieldName;
			} else if (XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/type")=="input-text"){
				QryFields+=",R."+XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/name");
			} else if (XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/type")=="input-number"){
				QryFields+=",R."+XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/name");
			} else if (XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/type")=="select-boolean"){
				QryFields+=",R."+XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/name");
			} else if (XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/type")=="external-key"){
				QryFields+=",R."+XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+j+"]/name");
			}
			
			LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"Field to retrieve for the list ->"+XaLibDom::GetElementValueByXPath(XmlDomDoc,XPathExpr+"["+ to_string(i+1) + "]/name"));
		};

	};

	QryFields+=" FROM XaMediaData R";

	LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"Query Fields ->"+QryFields);
	LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"Query Join ->"+QryJoin);
	
	string Qry=QryFields+QryJoin;
	Qry+=" WHERE R.id="+Id;

	LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"Query ->"+Qry);

    DbResMap DbRes=XaLibSql::FreeQuerySelect(DB_READ,Qry);

	vector<string> ReadFields=ReadPrepare({"XaMediaData"},"/XaMediaData/fieldset/field",0);

	RESPONSE.Content=ReadResponse(DbRes,ReadFields);
};
Beispiel #14
0
BOOL CPop3Connection::ReadCommandResponse()
{
	LPSTR pszOverFlowBuffer = NULL;
	char sBuf[1000] = {0};
	BOOL bSuccess = ReadResponse(sBuf, 1000, "\r\n", &pszOverFlowBuffer);
	if (pszOverFlowBuffer)
		delete [] pszOverFlowBuffer;
	
	return bSuccess;
}
bool CVTPSession::ReadResponse(int &code, std::string &line)
{
  std::vector<std::string> lines;
  if(ReadResponse(code, lines))
  {
    line = lines[lines.size()-1];
    return true;
  }
  return false;
}
Beispiel #16
0
void XaUserAddressPhone::ReadForUpdateFrm() {

	string Id=HTTP.GetHttpParam("id");

	vector<string> ReadFields=ReadPrepare({"XaUserAddressPhone"},"/XaUserAddressPhone/fieldset/field",0);

	DbResMap DbRes=XaLibSql::Select(DB_READ,"XaUserAddressPhone",{ReadFields},{"id"},{Id});

	RESPONSE.Content=ReadResponse(DbRes,ReadFields);
};
Beispiel #17
0
MsgPacket* MsgConnection::ReadResponse() {
	MsgPacket* p = new MsgPacket();

	if(!ReadResponse(p)) {
		delete p;
		return nullptr;
	}

	return p;
}
Beispiel #18
0
char*
CHttp::GetResponse(bool * stop )
{
	char		*response=NULL;
	DWORD		responselen = 0;

	if (!ReadResponse (&response, &responselen, stop  ) )
		return NULL;

	return response;
}
Beispiel #19
0
BOOL CPop3Connection::ReadStatResponse(int& nNumberOfMails, int& nTotalMailSize)
{
	//Must be connected to perform a "STAT"
	if(!m_bConnected)
		return FALSE;
	
	//retrieve the reponse
	LPSTR pszOverFlowBuffer = NULL;
	char sBuf[100];
	char* sMessageBuf = sBuf;
	if (!ReadResponse(sBuf, 100, "\r\n", &pszOverFlowBuffer))
	{
		if (pszOverFlowBuffer)
			delete [] pszOverFlowBuffer;
		
		TRACE(_T("Error retrieving the STAT response from the POP3 server"));
		return FALSE;
	}
	if (pszOverFlowBuffer)
		sMessageBuf = pszOverFlowBuffer;
	
	//determine if the response is an error
	if (strncmp(sMessageBuf,"+OK", 3) != 0)
	{
		TRACE(_T("POP3 server did not respond correctly to the STAT response\n"));
		return FALSE;
	}
	else
	{                                          
		//Parse out the Number of Mails and Total mail size values
		BOOL bGetNumber = TRUE;
		for (char* pszNum=sMessageBuf; *pszNum!='\0'; pszNum++)
		{
			if (*pszNum=='\t' || *pszNum==' ')
			{						
				if (bGetNumber)
				{
					nNumberOfMails = atoi(pszNum);
					m_nNumberOfMails = nNumberOfMails;
					bGetNumber = FALSE;
				}
				else
				{
					nTotalMailSize = atoi(pszNum);
					return TRUE;
				}
			}
		}
	}
	if (pszOverFlowBuffer)
		delete [] pszOverFlowBuffer;
	
	return FALSE; 
}
Beispiel #20
0
QString Pop3Client::doCommand(QString command,bool isMultiline)
{
//	qDebug() << "sending command: " << command << "\n";
        QString response;
        qint64 writeResult = m_sock.write(command.toAscii());
//        if (writeResult != command.size()) qDebug()<<"Could not write all bytes: ";
        if (writeResult > 0 && !m_sock.waitForBytesWritten(WRITE_TIMEOUT))  qDebug()<<"Could not write bytes from buffer: ";
        if (!ReadResponse(isMultiline,response))
                return "";
        return response;
}
Beispiel #21
0
int main()
{
	e4980a = CreateConnection(LCR, LCRPORT);

/*
	The following commands were used: Pl refer to the Agilent E4980a precision LCR meter.
	IssueCommand(e4980a,":SYST:PRES");		-> Preset
	IssueCommand(e4980a,":SYST:REST");		-> Reset		
	IssueCommand(e4980a,":MEM:CLE");		-> Clear Memory buffer
	IssueCommand(e4980a, "*IDN?\n");		-> Identity of Device
	IssueCommand(e4980a, ":FUNC:IMP:TYPE CSRS\n");	-> Measurement type of impedence (Ls-Rs,Cs-Rs...)
	IssueCommand(e4980a,":FREQ 1000");		-> Setting Frequency for measurment
	IssueCommand(e4980a,":VOLT:LEV 1");		-> Setting Voltage level for measurement
	IssueCommand(e4980a, "FETC:IMP:CORR?\n");	-> Fetching Impedence
*/

	IssueCommand(e4980a,":MEM:CLE");	
	IssueCommand(e4980a, "*IDN?\n");
	printf("%s\n", ReadResponse(e4980a, 10000));
	
    //	Initial Setup	
	IssueCommand(e4980a, ":FUNC:IMP:TYPE CSRS\n");
	IssueCommand(e4980a,":FREQ 1000");
	IssueCommand(e4980a,":VOLT:LEV 1");
		
    //Data recoreded will be stored in file name 1.csv in the same directory as binary file of form .out
	FILE* fp; 
	fp = fopen(OUTPUTFILE, "w");
	

	//initializing frequency sweep:
	//The frequency sweep should ideally be logarithmic, but the device limits the frequency range from 20 - 20khz
	//The following code has two parts [1000,5000,4001] and [5001,9981,250]

    int freq;
	for(freq = 0; freq <= 4000; ++freq)
        sample(freq);

	for(freq=4001; freq <= 9000; freq += 20)
        sample(freq);
	
	IssueCommand(e4980a, "*WAI\n");
			
	fprintf(fp, "%s\n", responseFromLCRMeter);
	fclose(fp);

	// Resetting .
	IssueCommand(e4980a,":FREQ 1000");
	IssueCommand(e4980a,":VOLT:LEV 0.2");
}
Beispiel #22
0
bool Pop3Client::Connect(QString host, unsigned port)
{
        m_sock.connectToHost(host,port);
        if (!m_sock.waitForConnected(CONNECT_TIMEOUT))
        {
                return false;
        }
        QString response;
        ReadResponse(false,response);
        if (response.startsWith("+OK"))
                state = Authorization;
        else
                return false;
        return true;
}
Beispiel #23
0
void XaUser::Read() {

	string Id=HTTP.GetHttpParam("id");

	vector<string> ReturnedFields={"id","name","surname","XaUserType_ID"};

	string Qry="SELECT X.id, X.name, X.surname, XaUserType.name AS XaUserType_ID FROM XaUser X";
	Qry+=" LEFT JOIN XaUserType ON X.XaUserType_ID=XaUserType.id";
	Qry+=" WHERE X.id="+Id;
	Qry+=" AND X.status=1";
	
	DbResMap DbRes=XaLibSql::FreeQuerySelect(DB_READ,Qry);

	RESPONSE.Content=ReadResponse(DbRes,ReturnedFields);
};
Beispiel #24
0
void XaMedia::View(){

	string Id=HTTP.GetHttpParam("id");
	
	string Qry="SELECT M.id,M.XaField_ID,M.preferred,M.position,M.XaDomainMediaCategory_ID,M.XaDomainMediaDescription_ID,D.file_name,CONCAT('data:',D.type,';base64,',D.data) data,D.type "
                   "FROM XaMedia M LEFT JOIN XaMediaData D ON D.XaMedia_ID=M.id WHERE M.status=1 AND M.id="+Id;

	LOG.Write("INF", __FILE__, __FUNCTION__,__LINE__,"Query ->"+Qry);

        DbResMap DbRes=XaLibSql::FreeQuerySelect(DB_READ,Qry);

	vector<string> ReadFields=ReadPrepare({"XaMediaComplete"},"/XaMediaComplete/fieldset/field",0);

	RESPONSE.Content=ReadResponse(DbRes,ReadFields);
};
bool CVTPSession::SendCommand(const std::string &command, int &code, std::vector<std::string> &lines)
{
  if(!SendCommand(command))
    return false;

  if(!ReadResponse(code, lines))
    return false;

  if(code < 200 || code > 299)
  {
    CLog::Log(LOGERROR, "CVTPSession::GetChannels - Failed with code: %d (%s)", code, lines[lines.size()-1].c_str());
    return false;
  }

  return true;
}
Beispiel #26
0
int RoboFocus::updateRFMotorSettings(double *duty, double *delay, double *ticks)
{

    DEBUGF(INDI::Logger::DBG_DEBUG, "Update Motor Settings: Duty (%g), Delay (%g), Ticks(%g)", *duty, *delay, *ticks);

    char rf_cmd[32] ;
    int robofocus_rc ;

    if (isSimulation())
    {
        *duty = 100;
        *delay = 0;
        *ticks = 0;
        return 0;
    }

    if(( *duty== 0 ) && (*delay== 0) && (*ticks== 0) ){

        strcpy(rf_cmd, "FC000000" ) ;

    } else {

        rf_cmd[0]=  'F' ;
        rf_cmd[1]=  'C' ;
        rf_cmd[2]= (char) *duty ;
        rf_cmd[3]= (char) *delay ;
        rf_cmd[4]= (char) *ticks ;
        rf_cmd[5]= '0' ;
        rf_cmd[6]= '0' ;
        rf_cmd[7]= '0' ;
        rf_cmd[8]=  0 ;

    }

    if ((robofocus_rc= SendCommand( rf_cmd)) < 0)
        return robofocus_rc;

    if ((robofocus_rc= ReadResponse(rf_cmd)) < 0)
            return robofocus_rc;

    *duty=  (float) rf_cmd[2] ;
    *delay= (float) rf_cmd[3] ;
    *ticks= (float) rf_cmd[4] ;

    return 0;
}
Beispiel #27
0
int RoboFocus::updateRFFirmware(char *rf_cmd)
{
    int robofocus_rc ;

    DEBUG(INDI::Logger::DBG_DEBUG, "Querying RoboFocus Firmware...");

    strcpy(rf_cmd, "FV000000" ) ;

    if ((robofocus_rc= SendCommand(rf_cmd)) < 0)
        return robofocus_rc;

    if (isSimulation())
        strcpy(rf_cmd, "SIM");
    else if ((robofocus_rc= ReadResponse(rf_cmd)) < 0)
        return robofocus_rc;

    return 0;
}
Beispiel #28
0
void sample(int frequency){
    char temp[] = ":FREQ ";
	sprintf (buffer, "%d",1000+frequency);
	strcat(temp,buffer);
	printf("%s\n",temp);
	IssueCommand(e4980a, temp);
	
	// introduce a time delay, before taking the next reading.		
    usleep(50);
    // sleep 50 mics, wait for oscillation to die.

	IssueCommand(e4980a, "*WAI\n");
	// Fetching the impedence.		
	IssueCommand(e4980a, "FETC:IMP:CORR?\n");
	IssueCommand(e4980a, "*WAI\n");
		
	strcat(responseFromLCRMeter,ReadResponse(e4980a,200));
	IssueCommand(e4980a, "*WAI\n");
}
Beispiel #29
0
bool Client::Notify(const char* method, Value& params, Value& result)
{
    log_trace();
    gettimeofday( &startTime_, 0 );
    result.SetInvalid();

    PreserveReceiveBuffer();
    ResetTransaction();

    if (Connect(result) &&
        GenerateRequest(method, params, true) &&
        GenerateHeader())
    {
        if (!WriteRequest(result))
        {
            // retry the connection
            Close();
            if (!Connect(result) ||
                !WriteRequest(result))
            {
                Reset();
                return false;
            }
        }
        // Not all notification require a response
        if (!TransportHasNotifyResponse())
        {
            requestId_.pop_front();
            return true;
        }
        // continue with the processing response
        if (ReadHeader(result) &&
            ReadResponse(result))
        {
            // don't process the response for a notification
            requestId_.pop_front();
            result.SetNull();
            return true;
        }
    }
    Reset();
    return false;
}
Beispiel #30
0
void XaUserLogin::ReadByToken() {

	int XaUser_ID=XaLibToken::ValidateToken(SESSION.Token);

	string SqlQry="SELECT name,surname FROM XaUser WHERE status=1 AND id=\""+FromIntToString(XaUser_ID)+"\"";
	DbResMap DbRes=XaLibSql::FreeQuerySelect(DB_SESSION,SqlQry);

	if (DbRes.size()==1 ){

		vector<string> ReturnedFields={"name","surname"};
		RESPONSE.Content=ReadResponse(DbRes,ReturnedFields);

	} else {

		LOG.Write("ERR", __FILE__, __FUNCTION__,__LINE__,"ERROR-56: User ID Does Not Exist Or Is not Unique");
		throw 56;
	}

};