Subversion Repositories ESP8266_P1_Meter

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 raymond 1
// SPDX-License-Identifier: LGPL-3.0-or-later
2
// Copyright 2016-2026 Hristo Gochkov, Mathieu Carbou, Emil Muratov, Will Miles
3
 
4
#include <ChunkPrint.h>
5
 
6
size_t ChunkPrint::write(uint8_t c) {
7
  // handle case where len is zero
8
  if (!_len) {
9
    return 0;
10
  }
11
  // skip first bytes until from is zero (bytes were already sent by previous chunk)
12
  if (_from) {
13
    _from--;
14
    return 1;
15
  }
16
  // write a maximum of len bytes
17
  if (_len - _index) {
18
    _destination[_index++] = c;
19
    return 1;
20
  }
21
  // we have finished writing len bytes, ignore the rest
22
  return 0;
23
}