MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / process_rawq

Method process_rawq

tools/python-3.11.9-amd64/Lib/telnetlib.py:427–496  ·  view source on GitHub ↗

Transfer from raw queue to cooked queue. Set self.eof when connection is closed. Don't block unless in the midst of an IAC sequence.

(self)

Source from the content-addressed store, hash-verified

425 self.option_callback = callback
426
427 def process_rawq(self):
428 """Transfer from raw queue to cooked queue.
429
430 Set self.eof when connection is closed. Don't block unless in
431 the midst of an IAC sequence.
432
433 """
434 buf = [b'', b'']
435 try:
436 while self.rawq:
437 c = self.rawq_getchar()
438 if not self.iacseq:
439 if c == theNULL:
440 continue
441 if c == b"\021":
442 continue
443 if c != IAC:
444 buf[self.sb] = buf[self.sb] + c
445 continue
446 else:
447 self.iacseq += c
448 elif len(self.iacseq) == 1:
449 # 'IAC: IAC CMD [OPTION only for WILL/WONT/DO/DONT]'
450 if c in (DO, DONT, WILL, WONT):
451 self.iacseq += c
452 continue
453
454 self.iacseq = b''
455 if c == IAC:
456 buf[self.sb] = buf[self.sb] + c
457 else:
458 if c == SB: # SB ... SE start.
459 self.sb = 1
460 self.sbdataq = b''
461 elif c == SE:
462 self.sb = 0
463 self.sbdataq = self.sbdataq + buf[1]
464 buf[1] = b''
465 if self.option_callback:
466 # Callback is supposed to look into
467 # the sbdataq
468 self.option_callback(self.sock, c, NOOPT)
469 else:
470 # We can't offer automatic processing of
471 # suboptions. Alas, we should not get any
472 # unless we did a WILL/DO before.
473 self.msg('IAC %d not recognized' % ord(c))
474 elif len(self.iacseq) == 2:
475 cmd = self.iacseq[1:2]
476 self.iacseq = b''
477 opt = c
478 if cmd in (DO, DONT):
479 self.msg('IAC %s %d',
480 cmd == DO and 'DO' or 'DONT', ord(opt))
481 if self.option_callback:
482 self.option_callback(self.sock, cmd, opt)
483 else:
484 self.sock.sendall(IAC + WONT + opt)

Callers 7

read_untilMethod · 0.95
read_allMethod · 0.95
read_someMethod · 0.95
read_very_eagerMethod · 0.95
read_eagerMethod · 0.95
read_lazyMethod · 0.95
expectMethod · 0.95

Calls 3

rawq_getcharMethod · 0.95
msgMethod · 0.95
sendallMethod · 0.45

Tested by

no test coverage detected