Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: MiniTLS-HTTPS-Example
buffer.h
00001 /* 00002 MiniTLS - A super trimmed down TLS/SSL Library for embedded devices 00003 Author: Donatien Garnier 00004 Copyright (C) 2013-2014 AppNearMe Ltd 00005 00006 This program is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU General Public License 00008 as published by the Free Software Foundation; either version 2 00009 of the License, or (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 *//** 00020 * \file buffer.h 00021 * \copyright Copyright (c) AppNearMe Ltd 2013 00022 * \author Donatien Garnier 00023 */ 00024 00025 #ifndef BUFFER_H_ 00026 #define BUFFER_H_ 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 #include "core/fwk.h" 00033 00034 typedef struct __buffer 00035 { 00036 uint8_t* bufdata; 00037 size_t size; 00038 00039 uint8_t* start; 00040 size_t first_byte_length; //In bits 00041 00042 uint8_t* end; 00043 size_t last_byte_length; //In bits 00044 00045 struct __buffer* next; 00046 00047 } buffer_t; 00048 00049 void buffer_init(buffer_t* pBuf, uint8_t* bufdata, size_t size); 00050 00051 void buffer_byref(buffer_t* pBuf, uint8_t* bufdata, size_t length); //New buffer by ref on a size_t array, no malloc (useful on PIC for instance) 00052 00053 buffer_t* buffer_new(size_t size); //malloc 00054 00055 uint8_t* buffer_data(buffer_t* pBuf); 00056 00057 void buffer_reset(buffer_t* pBuf); 00058 00059 size_t buffer_size(buffer_t* pBuf); 00060 00061 size_t buffer_length(buffer_t* pBuf); 00062 00063 size_t buffer_space(buffer_t* pBuf); 00064 00065 bool buffer_empty(buffer_t* pBuf); 00066 00067 void buffer_set_length(buffer_t* pBuf, size_t length); 00068 00069 size_t buffer_last_byte_length(buffer_t* pBuf); 00070 00071 void buffer_set_last_byte_length(buffer_t* pBuf, size_t length); 00072 00073 size_t buffer_bits_count(buffer_t* pBuf); 00074 00075 void buffer_write_byte(buffer_t* pBuf, uint8_t b); 00076 00077 void buffer_write_bit(buffer_t* pBuf, uint8_t b); 00078 00079 #if 0 00080 size_t buffer_read_byte(buffer_t* pBuf, uint8_t b); 00081 00082 size_t buffer_read_bit(buffer_t* pBuf, uint8_t b); 00083 #endif 00084 00085 buffer_t* buffer_next(buffer_t* pBuf); 00086 00087 void buffer_set_next(buffer_t* pBuf, buffer_t* pNextBuf); 00088 00089 void buffer_append(buffer_t* pBuf, buffer_t* pAppBuf); 00090 00091 void buffer_unlink(buffer_t* pBuf, buffer_t* pLinkedBuf); 00092 00093 size_t buffer_total_size(buffer_t* pBuf); 00094 00095 size_t buffer_total_length(buffer_t* pBuf); 00096 00097 void buffer_set_total_length(buffer_t* pBuf, size_t length); 00098 00099 void buffer_free(buffer_t* pBuf); 00100 00101 //Debug 00102 void buffer_dump(buffer_t* pBuf); 00103 00104 #ifdef __cplusplus 00105 } 00106 #endif 00107 00108 #endif /* BUFFER_H_ */
Generated on Wed Jul 13 2022 00:22:54 by
1.7.2