示例#1
0
int L4Handler::init(HttpReq &req, const GSockAddr *pGSockAddr, const char *pIP, int iIpLen)
{
    int ret = m_pL4conn->init(pGSockAddr);
    if (ret != 0)
        return ret;
    
    int hasSlashR = 1; //"\r\n"" or "\n"
    LoopBuf *pBuff = m_pL4conn->getBuf();
    pBuff->append(req.getOrgReqLine(), req.getHttpHeaderLen());
    char *pBuffEnd = pBuff->end();
    assert(pBuffEnd[-1] == '\n');
    if (pBuffEnd[-2] == 'n')
        hasSlashR = 0;
    else
    {
        assert(pBuffEnd[-2] == '\r');
    }
    
    pBuff->used( -1 * hasSlashR - 1);
    pBuff->append("X-Forwarded-For", 15);
    pBuff->append(": ", 2);
    pBuff->append(pIP, iIpLen);
    if (hasSlashR)
        pBuff->append("\r\n\r\n", 4);
    else
        pBuff->append("\n\n", 2);
    
    continueRead();
    if ( D_ENABLED( DL_LESS ) )
    {
        LOG_D ((getLogger(), "[%s] L4Handler: init web socket, reqheader [%s], len [%d]",
                getLogId(), req.getOrgReqLine(), req.getHttpHeaderLen() ));
    }
    return 0;
}
void
OpmlParser::slotAddData( KIO::Job *job, const QByteArray &data )
{
    Q_UNUSED( job )

    QXmlStreamReader::addData( data );

    // parse more data
    continueRead();
}
bool
OpmlParser::read()
{
    m_buffer.clear();
    m_actionStack.clear();
    m_actionStack.push( &( OpmlParser::sd.startAction ) );
    setNamespaceProcessing( false );

    return continueRead();
}
void SensorFileSysWalker::runThreadReader( void *p_arg ) {
	// produce sensor output - first time
	produceSensorData();

	// read in cycle
	while( continueRunFlag ) {
		// wait event or interrupt
		continueRead();
	}

	// cleanup
	closeWaitHandle();
}
示例#5
0
uint8_t GPS_MTK3339::Read(){
    #ifdef GPS_DEBUG_READ_VERBOSE
        GPS_DEBUG_READ_PRINTLN("READ GPS");
    #endif
    
    switch(_machineState){
        case GPS_MS_INIT:
        case GPS_MS_ERROR:
        case GPS_MS_READY:
            return startRead();
    }
    return continueRead();
}
示例#6
0
void
OpmlParser::downloadResult( KJob *job )
{
    // parse more data
    continueRead();

    KIO::TransferJob *transferJob = dynamic_cast<KIO::TransferJob *>( job );
    if( job->error() || ( transferJob && transferJob->isErrorPage() ) )
    {
        QString errorMessage =
            i18n( "Reading OPML podcast from %1 failed with error:\n", m_url.url() );
        errorMessage = errorMessage.append( job->errorString() );

//        emit statusBarSorryMessage( errorMessage );
    }

    m_transferJob = 0;
}
示例#7
0
uint8_t GPS_MTK3339::startRead(){
    #ifdef GPS_DEBUG_READ_VERBOSE
        if(serial_available() > 0){
            GPS_DEBUG_READ_PRINTLN("GPS DATA IN BUFFER");
        }
        GPS_DEBUG_READ_PRINTLN("READ GPS");
    #endif
    while(serial_available() > 0){
        uint8_t b = serial_read();
        if(b == GPS_START_DELIM){
            memset(Buffer, 0x00, sizeof(Buffer));
            Buffer[0] = b;
            _bufferOffset = 1;
            _machineState = GPS_MS_READING;
            return continueRead();
        }
    }
    return GPS_STATUS_NODATA;
}