• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

randombit / botan / 12976993364

26 Jan 2025 05:51PM UTC coverage: 91.251% (-0.005%) from 91.256%
12976993364

push

github

web-flow
Merge pull request #4599 from randombit/jack/split-api-and-compiler-headers

Split compiler.h into two headers

93963 of 102972 relevant lines covered (91.25%)

11437005.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.37
/src/lib/filters/out_buf.cpp
1
/*
2
* Pipe Output Buffer
3
* (C) 1999-2007,2011 Jack Lloyd
4
*     2012 Markus Wanner
5
*
6
* Botan is released under the Simplified BSD License (see license.txt)
7
*/
8

9
#include <botan/internal/out_buf.h>
10

11
#include <botan/assert.h>
12
#include <botan/internal/secqueue.h>
13

14
namespace Botan {
15

16
/*
17
* Read data from a message
18
*/
19
size_t Output_Buffers::read(uint8_t output[], size_t length, Pipe::message_id msg) {
116✔
20
   SecureQueue* q = get(msg);
116✔
21
   if(q) {
116✔
22
      return q->read(output, length);
116✔
23
   }
24
   return 0;
25
}
26

27
/*
28
* Peek at data in a message
29
*/
30
size_t Output_Buffers::peek(uint8_t output[], size_t length, size_t stream_offset, Pipe::message_id msg) const {
1✔
31
   SecureQueue* q = get(msg);
1✔
32
   if(q) {
1✔
33
      return q->peek(output, length, stream_offset);
1✔
34
   }
35
   return 0;
36
}
37

38
/*
39
* Check available bytes in a message
40
*/
41
size_t Output_Buffers::remaining(Pipe::message_id msg) const {
76✔
42
   SecureQueue* q = get(msg);
76✔
43
   if(q) {
76✔
44
      return q->size();
76✔
45
   }
46
   return 0;
47
}
48

49
/*
50
* Return the total bytes of a message that have already been read.
51
*/
52
size_t Output_Buffers::get_bytes_read(Pipe::message_id msg) const {
8✔
53
   SecureQueue* q = get(msg);
8✔
54
   if(q) {
8✔
55
      return q->get_bytes_read();
8✔
56
   }
57
   return 0;
58
}
59

60
/*
61
* Add a new output queue
62
*/
63
void Output_Buffers::add(SecureQueue* queue) {
72✔
64
   BOTAN_ASSERT(queue, "queue was provided");
72✔
65

66
   BOTAN_ASSERT(m_buffers.size() < m_buffers.max_size(), "Room was available in container");
72✔
67

68
   m_buffers.push_back(std::unique_ptr<SecureQueue>(queue));
72✔
69
}
72✔
70

71
/*
72
* Retire old output queues
73
*/
74
void Output_Buffers::retire() {
65✔
75
   for(auto& buf : m_buffers) {
405✔
76
      if(buf && buf->empty()) {
275✔
77
         buf.reset();
298✔
78
      }
79
   }
80

81
   while(!m_buffers.empty() && !m_buffers[0]) {
88✔
82
      m_buffers.pop_front();
23✔
83
      m_offset = m_offset + Pipe::message_id(1);
23✔
84
   }
85
}
65✔
86

87
/*
88
* Get a particular output queue
89
*/
90
SecureQueue* Output_Buffers::get(Pipe::message_id msg) const {
201✔
91
   if(msg < m_offset) {
201✔
92
      return nullptr;
93
   }
94

95
   BOTAN_ASSERT(msg < message_count(), "Message number is in range");
×
96

97
   return m_buffers[msg - m_offset].get();
201✔
98
}
99

100
/*
101
* Return the total number of messages
102
*/
103
Pipe::message_id Output_Buffers::message_count() const {
452✔
104
   return (m_offset + m_buffers.size());
201✔
105
}
106

107
/*
108
* Output_Buffers Constructor
109
*/
110
Output_Buffers::Output_Buffers() {
18✔
111
   m_offset = 0;
18✔
112
}
18✔
113

114
}  // namespace Botan
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc