// ftpd is a server implementation based on the following: // - RFC 959 (https://tools.ietf.org/html/rfc959) // - RFC 3659 (https://tools.ietf.org/html/rfc3659) // - suggested implementation details from https://cr.yp.to/ftp/filesystem.html // // Copyright (C) 2020 Michael Theall // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #pragma once #include #include class IOBuffer { public: ~IOBuffer (); IOBuffer (std::size_t size_); char *freeArea () const; std::size_t freeSize () const; void markFree (std::size_t size_); char *usedArea () const; std::size_t usedSize () const; void markUsed (std::size_t size_); bool empty () const; std::size_t capacity () const; void clear (); void coalesce (); private: std::unique_ptr m_buffer; std::size_t const m_size; std::size_t m_start = 0; std::size_t m_end = 0; };