/** * Handel incomming data from Client */ void WebSocketsServer::handleClientData(void) { WSclient_t * client; for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) { client = &_clients[i]; if(clientIsConnected(client)) { int len = client->tcp.available(); if(len > 0) { switch(client->status) { case WSC_HEADER: handleHeader(client); break; case WSC_CONNECTED: WebSockets::handleWebsocket(client); break; default: WebSockets::clientDisconnect(client, 1002); break; } } } #ifdef ESP8266 delay(0); #endif } }
/** * Handel incomming data from Client */ void WebSocketsServer::handleClientData(void) { WSclient_t * client; for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) { client = &_clients[i]; if(clientIsConnected(client)) { int len = client->tcp->available(); if(len > 0) { //DEBUG_WEBSOCKETS("[WS-Server][%d][handleClientData] len: %d\n", client->num, len); switch(client->status) { case WSC_HEADER: { String headerLine = client->tcp->readStringUntil('\n'); handleHeader(client, &headerLine); } break; case WSC_CONNECTED: WebSockets::handleWebsocket(client); break; default: WebSockets::clientDisconnect(client, 1002); break; } } } #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) delay(0); #endif } }
void BlockStatement::aggregate() { // Create scope. scope = new SymbolTable(SymbolTable::getActiveScope()); // If this scope has a name, register that as // a member of the containing scope. if(name) { // Assumes this code will never get executed by the outermost block (before there is an active scope). SymbolTable* outer = SymbolTable::getActiveScope(); PackageDefinition* package = new PackageDefinition(name->getValue(), scope); // Shove the this package into the containing outer scope. outer->put(package, getSourcePosition()); // Create a back-reference, so the scope knows it defines a new package, // rather than just sharing a private subset of the outer scope's package. scope->setPackage(package); } // Enter the created scope. SymbolTable::enterScope(scope); ListNode<Statement*>::ListType& list = statements->getList(); // First gather all constant definitions in this scope. for(size_t i = 0; i < list.size(); i++) { Statement* statement = list[i]; if(statement->getStatementType() == Statement::CONSTANT_DECLARATION) { statement->aggregate(); } } // Next, if this is the main block, calculate the header. if(handleHeader(list)) { // Now, check out all the other statements. for(size_t i = 0; i < list.size(); i++) { Statement* statement = list[i]; switch(statement->getStatementType()) { // Skip already handled cases. case Statement::CONSTANT_DECLARATION: case Statement::HEADER: break; // Aggregate the rest. default: statement->aggregate(); break; } } } SymbolTable::exitScope(); }
void FastCGITransport::onHeader(std::unique_ptr<folly::IOBuf> key_chain, std::unique_ptr<folly::IOBuf> value_chain) { Cursor cursor(key_chain.get()); std::string key = cursor.readFixedString(key_chain->computeChainDataLength()); cursor = Cursor(value_chain.get()); std::string value = cursor.readFixedString( value_chain->computeChainDataLength()); handleHeader(key, value); }
/** * Handel incomming data from Client */ void WebSocketsClient::handleClientData(void) { int len = _client.tcp->available(); if(len > 0) { switch(_client.status) { case WSC_HEADER: handleHeader(&_client); break; case WSC_CONNECTED: WebSockets::handleWebsocket(&_client); break; default: WebSockets::clientDisconnect(&_client, 1002); break; } } #ifdef ESP8266 delay(0); #endif }
void ArchiveParser::run (Archive &archive) { ChannelIterator channel (archive); ValueIterator value (archive); stdString parameter, arg; bool go = true; while (go && nextLine ()) { if (getParameter (parameter, arg)) { if (parameter == "channel") { if (archive.findChannelByName (arg, channel)) { _last_time = channel->getLastTime (); } else { if (! archive.addChannel (arg, channel)) { printf("Cannot add channel '%s' to archive\n", arg.c_str()); return; } _last_time = nullTime; } } } else { if (getLine() == "Header") go = handleHeader(archive); else if (getLine() == "CtrlInfo") go = handleCtrlInfo(channel); else go = handleValue(channel); } } }
/** * Handel incomming data from Client */ void WebSocketsClient::handleClientData(void) { int len = _client.tcp->available(); if(len > 0) { switch(_client.status) { case WSC_HEADER: { String headerLine = _client.tcp->readStringUntil('\n'); handleHeader(&_client, &headerLine); } break; case WSC_CONNECTED: WebSockets::handleWebsocket(&_client); break; default: WebSockets::clientDisconnect(&_client, 1002); break; } } #if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266) delay(0); #endif }
HttpConnection::ProcessResult HttpConnection::process() { ProcessResult result = PROCESS_RESULT_NOT_FOUND; switch (mState) { case STATE_PRE_METHOD: if (eatSpaces()) return PROCESS_RESULT_NOT_FOUND; mState = STATE_METHOD; // No break. case STATE_METHOD: { result = locateRegion(' ', '\r', &mMethod); if (result == PROCESS_RESULT_FOUND) mState = STATE_PRE_URI; } break; case STATE_PRE_URI: if (eatSpaces()) return PROCESS_RESULT_NOT_FOUND; mState = STATE_URI; // No break; case STATE_URI: { result = locateRegion(' ', '\r', &mUri); if (result == PROCESS_RESULT_FOUND) mState = STATE_PRE_VERSION; } break; case STATE_PRE_VERSION: if (eatSpaces()) return PROCESS_RESULT_NOT_FOUND; mState = STATE_VERSION; // No break; case STATE_VERSION: { WriteBuffer *version; result = locateRegion('\r', ' ', &version); if (result == PROCESS_RESULT_FOUND) { if (!handleVersion(version)) return PROCESS_RESULT_ERROR; HttpRequest::Embryo embryo(this, mMethod, mUri, version); mHttpRequest = mHttpServer->instantiateHttpRequest(&embryo); if (!mHttpRequest) mHttpRequest = new SimpleHttpRequest(&embryo, "501 Not Implemented"); delete mMethod; delete mUri; delete version; mState = STATE_REQUEST_LINE_EOL; } } break; case STATE_REQUEST_LINE_EOL: { if (mInputBuffer.pop() != '\n') return PROCESS_RESULT_ERROR; result = PROCESS_RESULT_FOUND; mState = STATE_PRE_KEY; } break; case STATE_PRE_KEY: if (eatSpaces()) return PROCESS_RESULT_NOT_FOUND; if (mInputBuffer.charAt(0) == '\r') { mInputBuffer.pop(); result = PROCESS_RESULT_FOUND; mState = STATE_HEADERS_END_EOL; break; } mState = STATE_KEY; // No break. case STATE_KEY: { result = locateRegion(':', '\r', &mMethod); if (result == PROCESS_RESULT_FOUND) mState = STATE_PRE_VALUE; } break; case STATE_PRE_VALUE: if (eatSpaces()) return PROCESS_RESULT_NOT_FOUND; mState = STATE_VALUE; // No break; case STATE_VALUE: { result = locateRegion('\r', '\n', &mUri); if (result == PROCESS_RESULT_FOUND) { handleHeader(mMethod, mUri); mHttpRequest->receiveHeader(mMethod, mUri); delete mMethod; delete mUri; mState = STATE_HEADER_EOL; } } break; case STATE_HEADER_EOL: { if (mInputBuffer.pop() != '\n') return PROCESS_RESULT_ERROR; result = PROCESS_RESULT_FOUND; mState = STATE_PRE_KEY; } break; case STATE_HEADERS_END_EOL: { if (mInputBuffer.pop() != '\n') return PROCESS_RESULT_ERROR; result = PROCESS_RESULT_FOUND; if (mHttpRequest->mDataLeft == 0) { mHttpRequest->receiveEnd(); mHttpRequest = 0; result = PROCESS_RESULT_REQUEST_END; } else { mState = STATE_DATA; } } break; case STATE_DATA: { if (mInputBuffer.length() > mHttpRequest->mDataLeft) { WriteBuffer *buffer = mInputBuffer.region(0, mHttpRequest->mDataLeft); mInputBuffer.popped(mHttpRequest->mDataLeft); mHttpRequest->mDataLeft = 0; mHttpRequest->receiveData(buffer); delete buffer; } else { mHttpRequest->receiveData(&mInputBuffer); mHttpRequest->mDataLeft -= mInputBuffer.length(); mInputBuffer.poppedAll(); } if (mHttpRequest->mDataLeft == 0) { mHttpRequest->receiveEnd(); mHttpRequest = 0; result = PROCESS_RESULT_REQUEST_END; } } break; } return result; }
void WorksheetSubStreamHandler::handleRecord(Record* record) { if (!record) return; const unsigned type = record->rtti(); if (type == BottomMarginRecord::id) handleBottomMargin(static_cast<BottomMarginRecord*>(record)); else if (type == BoolErrRecord::id) handleBoolErr(static_cast<BoolErrRecord*>(record)); else if (type == BlankRecord::id) handleBlank(static_cast<BlankRecord*>(record)); else if (type == CalcModeRecord::id) handleCalcMode(static_cast<CalcModeRecord*>(record)); else if (type == ColInfoRecord::id) handleColInfo(static_cast<ColInfoRecord*>(record)); else if (type == DataTableRecord::id) handleDataTable(static_cast<DataTableRecord*>(record)); else if (type == FormulaRecord::id) handleFormula(static_cast<FormulaRecord*>(record)); else if (type == FooterRecord::id) handleFooter(static_cast<FooterRecord*>(record)); else if (type == HeaderRecord::id) handleHeader(static_cast<HeaderRecord*>(record)); else if (type == LabelRecord::id) handleLabel(static_cast<LabelRecord*>(record)); else if (type == LabelSSTRecord::id) handleLabelSST(static_cast<LabelSSTRecord*>(record)); else if (type == LeftMarginRecord::id) handleLeftMargin(static_cast<LeftMarginRecord*>(record)); else if (type == MergedCellsRecord::id) handleMergedCells(static_cast<MergedCellsRecord*>(record)); else if (type == MulBlankRecord::id) handleMulBlank(static_cast<MulBlankRecord*>(record)); else if (type == MulRKRecord::id) handleMulRK(static_cast<MulRKRecord*>(record)); else if (type == NumberRecord::id) handleNumber(static_cast<NumberRecord*>(record)); else if (type == RightMarginRecord::id) handleRightMargin(static_cast<RightMarginRecord*>(record)); else if (type == RKRecord::id) handleRK(static_cast<RKRecord*>(record)); else if (type == RowRecord::id) handleRow(static_cast<RowRecord*>(record)); else if (type == RStringRecord::id) handleRString(static_cast<RStringRecord*>(record)); else if (type == SharedFormulaRecord::id) handleSharedFormula(static_cast<SharedFormulaRecord*>(record)); else if (type == StringRecord::id) handleString(static_cast<StringRecord*>(record)); else if (type == TopMarginRecord::id) handleTopMargin(static_cast<TopMarginRecord*>(record)); else if (type == HLinkRecord::id) handleHLink(static_cast<HLinkRecord*>(record)); else if (type == NoteRecord::id) handleNote(static_cast<NoteRecord*>(record)); else if (type == ObjRecord::id) handleObj(static_cast<ObjRecord*>(record)); else if (type == TxORecord::id) handleTxO(static_cast<TxORecord*>(record)); else if (type == BOFRecord::id) handleBOF(static_cast<BOFRecord*>(record)); else if (type == DefaultRowHeightRecord::id) handleDefaultRowHeight(static_cast<DefaultRowHeightRecord*>(record)); else if (type == DefaultColWidthRecord::id) handleDefaultColWidth(static_cast<DefaultColWidthRecord*>(record)); else if (type == SetupRecord::id) handleSetup(static_cast<SetupRecord*>(record)); else if (type == HCenterRecord::id) handleHCenter(static_cast<HCenterRecord*>(record)); else if (type == VCenterRecord::id) handleVCenter(static_cast<VCenterRecord*>(record)); else if (type == ZoomLevelRecord::id) handleZoomLevel(static_cast<ZoomLevelRecord*>(record)); else if (type == 0xA) {} //EofRecord else if (type == DimensionRecord::id) handleDimension(static_cast<DimensionRecord*>(record)); else if (type == MsoDrawingRecord::id) handleMsoDrawing(static_cast<MsoDrawingRecord*>(record)); else if (type == Window2Record::id) handleWindow2(static_cast<Window2Record*>(record)); else if (type == PasswordRecord::id) handlePassword(static_cast<PasswordRecord*>(record)); else if (type == BkHimRecord::id) handleBkHim(static_cast<BkHimRecord*>(record)); else if (type == VerticalPageBreaksRecord::id) handleVerticalPageBreaksRecord(static_cast<VerticalPageBreaksRecord*>(record)); else if (type == HorizontalPageBreaksRecord::id) handleHorizontalPageBreaksRecord(static_cast<HorizontalPageBreaksRecord*>(record)); else if (type == CondFmtRecord::id) handleCondFmtRecord(static_cast<CondFmtRecord*>(record)); else if (type == CFRecord::id) handleCFRecord(static_cast<CFRecord*>(record)); else { //std::cout << "Unhandled worksheet record with type=" << type << " name=" << record->name() << std::endl; } }
/* * dispHelp */ static int dispHelp( char *str, VTAB *tab ) { EVENT ev; bool done; int lastline; int start; SAREA use; SAREA line; char helpname[81]; ignoreMouseRelease = true; helpSet( str, helpname, sizeof( helpname ) ); if( uivopen( &helpScreen ) == NULL ) return( HELP_NO_VOPEN ); use.height = helpScreen.area.height - 3; use.width = helpScreen.area.width; use.col = 0; line.height = 1; line.width = helpScreen.area.width; line.col = 0; topPos = HelpTell( helpFileHdl ); mygetline(); handleHeader( &start, &line ); use.row = start; use.height -= start; handleFooter( &start, &use, &line ); setupScrollBar( &use ); if( helpLines > 0 ) { maxPos = helpLines + 1; helpPos = HelpMemAlloc( maxPos * sizeof( *helpPos ) ); } else { maxPos = 0; helpPos = NULL; } maxLine = 0; lastHelpLine = 0; save_line( 0, topPos ); currLine = helpStack->line; seek_line( currLine ); lastline = currLine + use.height; done = false; ev = EV_NO_EVENT; while( !done ) { currentColour = C_PLAIN; currentAttr = AT( ATTR_NORMAL ); if( lastline != currLine ) { lastline = scrollHelp( &use, lastline, ( ev != EV_NO_EVENT ) ); } ev = hlpwait( tab ); switch( ev ) { case E_UP: case EV_CURSOR_UP: case EV_TOP: if( currLine > 0 ) { --currLine; } break; case E_DOWN: case EV_CURSOR_DOWN: case EV_BOTTOM: ++currLine; if( maxLine != 0 && currLine+use.height > maxLine ) { --currLine; } break; case EV_SCROLL_VERTICAL: currLine = vGadget.pos; break; case EV_PAGE_UP: currLine -= use.height; if( currLine < 0 ) { currLine = 0; } break; case EV_PAGE_DOWN: currLine += use.height; if( maxLine != 0 && currLine >= maxLine ) { currLine -= use.height; } break; default: done = true; break; } } clearline(); uivclose( &helpScreen ); if( helpPos != NULL ) { HelpMemFree( helpPos ); helpPos = NULL; } return( HELP_OK ); }