packet.h (1872B)
1 /* 2 * libdivecomputer 3 * 4 * Copyright (C) 2023 Jef Driesen 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 19 * MA 02110-1301 USA 20 */ 21 22 #ifndef DC_PACKET_H 23 #define DC_PACKET_H 24 25 #include <libdivecomputer/common.h> 26 #include <libdivecomputer/context.h> 27 #include <libdivecomputer/iostream.h> 28 29 #ifdef __cplusplus 30 extern "C" { 31 #endif /* __cplusplus */ 32 33 /** 34 * Create a packet I/O stream layered on top of another base I/O stream. 35 * 36 * This layered I/O allows reading and writing a byte stream from the 37 * underlying packet oriented transport. It changes the packet oriented 38 * base transport into a stream oriented transport. 39 * 40 * @param[out] iostream A location to store the packet I/O stream. 41 * @param[in] context A valid context. 42 * @param[in] base A valid I/O stream. 43 * @param[in] isize The input packet size in bytes. 44 * @param[in] osize The output packet size in bytes. 45 * @returns #DC_STATUS_SUCCESS on success, or another #dc_status_t code 46 * on failure. 47 */ 48 dc_status_t 49 dc_packet_open (dc_iostream_t **iostream, dc_context_t *context, dc_iostream_t *base, size_t isize, size_t osize); 50 51 #ifdef __cplusplus 52 } 53 #endif /* __cplusplus */ 54 #endif /* DC_PACKET_H */