MCPcopy Create free account
hub / github.com/apache/trafficserver / fgets

Method fgets

src/api/InkAPIInternal.cc:488–524  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

486}
487
488char *
489FileImpl::fgets(char *buf, size_t length)
490{
491 char *e;
492 size_t pos;
493
494 if (length == 0) {
495 return nullptr;
496 }
497
498 if (!m_buf || (m_bufpos < (length - 1))) {
499 pos = m_bufpos;
500
501 if (fread(nullptr, length - 1) < 0) {
502 return nullptr;
503 }
504
505 if (!m_bufpos && (pos == m_bufpos)) {
506 return nullptr;
507 }
508 }
509
510 e = (char *)memchr(m_buf, '\n', m_bufpos);
511 if (e) {
512 e += 1;
513 if (length > (size_t)(e - m_buf + 1)) {
514 length = e - m_buf + 1;
515 }
516 }
517
518 ssize_t rlen = fread(buf, length - 1);
519 if (rlen >= 0) {
520 buf[rlen] = '\0';
521 }
522
523 return buf;
524}
525
526////////////////////////////////////////////////////////////////////
527//

Callers 1

TSfgetsFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected