/usr/include/luasandbox/util/output_buffer.h is in libluasandbox-dev 1.2.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/** Data stream output buffer @file */
#ifndef luasandbox_util_output_buffer_h_
#define luasandbox_util_output_buffer_h_
#include <stdbool.h>
#include "util.h"
#define LSB_OUTPUT_SIZE 1024
typedef struct lsb_output_buffer {
char *buf;
size_t maxsize;
size_t size;
size_t pos;
} lsb_output_buffer;
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Initialize the provided input buffer
*
* @param b Output buffer
* @param max_message_size The maximum message size the buffer will handle
* before erroring
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_init_output_buffer(lsb_output_buffer *b, size_t max_message_size);
/**
* Frees the memory internally allocated by the buffer and resets the state
*
* @param b Output buffer
*/
LSB_UTIL_EXPORT void lsb_free_output_buffer(lsb_output_buffer *b);
/**
* Resize the output buffer when more space is needed.
*
* @param b Output buffer to resize.
* @param needed Number of additional bytes needed.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_expand_output_buffer(lsb_output_buffer *b,
size_t needed);
/**
* Append a character to the output buffer.
*
* @param b Pointer the b buffer.
* @param ch Character to append to the b.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_outputc(lsb_output_buffer *b, char ch);
/**
* Append a formatted string to the output buffer.
*
* @param b Pointer the b buffer.
* @param fmt Printf format specifier.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_outputf(lsb_output_buffer *b, const char *fmt, ...);
/**
* Append a fixed string to the output buffer.
*
* @param b Pointer the b buffer.
* @param str String to append to the b.
* @param len Length of the string to append
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value
lsb_outputs(lsb_output_buffer *b, const char *str, size_t len);
/**
* More efficient output of a double to a string. NaN/Inf check and then calls
* lsb_outputfd.
*
* @param b Pointer the output buffer.
* @param d Double value to convert to a string.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_outputd(lsb_output_buffer *b, double d);
/**
* More efficient output of a double to a string; no NaN or Inf outputs.
*
* @param b Pointer the output buffer.
* @param d Double value to convert to a string.
*
* @return lsb_err_value NULL on success error message on failure
*/
LSB_UTIL_EXPORT lsb_err_value lsb_outputfd(lsb_output_buffer *b, double d);
#ifdef __cplusplus
}
#endif
#endif
|