1 /* 2 * Copyright (C) 2020-2021 Bareos GmbH & Co. KG 3 * Copyright (C) 2010 SCALITY SA. All rights reserved. 4 * http://www.scality.com 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions are 8 * met: 9 * 10 * Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 13 * Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY SCALITY SA ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 * DISCLAIMED. IN NO EVENT SHALL SCALITY SA OR CONTRIBUTORS BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 26 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 * 29 * The views and conclusions contained in the software and documentation 30 * are those of the authors and should not be interpreted as representing 31 * official policies, either expressed or implied, of SCALITY SA. 32 * 33 * https://github.com/scality/Droplet 34 */ 35 #ifndef BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_SBUF_H_ 36 #define BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_SBUF_H_ 37 38 typedef struct { 39 char* buf; 40 size_t len; 41 size_t allocated; 42 } dpl_sbuf_t; 43 44 /* PROTO sbuf.c */ 45 dpl_sbuf_t* dpl_sbuf_new(size_t size); 46 dpl_sbuf_t* dpl_sbuf_new_from_str(const char* str); 47 dpl_status_t dpl_sbuf_add(dpl_sbuf_t* sb, const char* buf, size_t len); 48 dpl_status_t dpl_sbuf_add_str(dpl_sbuf_t* sb, const char* str); 49 dpl_status_t __attribute__((format(printf, 2, 3))) 50 dpl_sbuf_add_str_fmt(dpl_sbuf_t* sb, const char* format, ...); 51 dpl_sbuf_t* dpl_sbuf_dup(const dpl_sbuf_t* src); 52 char* dpl_sbuf_get_str(dpl_sbuf_t* sbuf); 53 void dpl_sbuf_free(dpl_sbuf_t* sb); 54 void dpl_sbuf_print(FILE* f, dpl_sbuf_t* sb); 55 dpl_status_t dpl_sbuf_url_encode(dpl_sbuf_t* sb); 56 57 #endif // BAREOS_DROPLET_LIBDROPLET_INCLUDE_DROPLET_SBUF_H_ 58