/usr/include/dnscore/output_stream.h is in libyadifa-dev 2.1.6-1.
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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | /*------------------------------------------------------------------------------
*
* Copyright (c) 2011-2016, EURid. All rights reserved.
* The YADIFA TM software product is provided under the BSD 3-clause license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of EURid nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*------------------------------------------------------------------------------
*
*/
/** @ingroup dnscore
*
*/
/*----------------------------------------------------------------------------*/
#ifndef _OUTPUT_STREAM_H
#define _OUTPUT_STREAM_H
#include <dnscore/sys_types.h>
#include <dnscore/dnsname.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct output_stream output_stream;
typedef ya_result output_stream_write_method(output_stream* stream,const u8* buffer,u32 len);
typedef ya_result output_stream_flush_method(output_stream* stream);
typedef void output_stream_close_method(output_stream* stream);
typedef ya_result output_stream_skip_method(output_stream* stream,u32 byte_count);
typedef struct output_stream_vtbl output_stream_vtbl;
struct output_stream_vtbl
{
output_stream_write_method* write;
output_stream_flush_method* flush;
output_stream_close_method* close;
const char* __class__; /* MUST BE A UNIQUE POINTER, ie: One defined in the class's .c file
The name should be unique in order to avoid compiler tricks
*/
/* Add your inheritable methods here */
};
struct output_stream
{
void* data;
const output_stream_vtbl* vtbl;
};
#define output_stream_class(os__) ((os__)->vtbl)
#define output_stream_class_name(os__) ((os__)->vtbl->__class__)
#define output_stream_write(os__,buffer__,len__) (os__)->vtbl->write((os__),(const u8*)(buffer__),(len__))
#define output_stream_flush(os__) (os__)->vtbl->flush(os__)
#define output_stream_close(os__) (os__)->vtbl->close(os__)
#define output_stream_skip(os__,len__) (os__)->vtbl->skip((os__),(len__))
#define output_stream_valid(os__) ((os__)->vtbl != NULL)
ya_result output_stream_write_nu32(output_stream* os, u32 value);
ya_result output_stream_write_nu16(output_stream* os, u16 value);
/*
* ya_result output_stream_write_u8(output_stream* os, u8 value);
*/
static inline ya_result
output_stream_write_u8(output_stream* os, u8 value)
{
return output_stream_write(os, &value, 1);
}
ya_result output_stream_write_u16(output_stream* os, u16 value);
/*
* PACKED unsigned 32 bits
*
* The integer is divided into 7 bits packets (lsb -> msb)
* The 8th bit is set until the end is reached
*
* [ 0.. 127] => [ 0x00 .. 0x7f]
* [128..16384] => [0x80 0x01 .. 0xff 0x7f]
*
*/
ya_result output_stream_write_pu32(output_stream* os, u32 value);
ya_result output_stream_write_dnsname(output_stream* os, const u8* name);
ya_result output_stream_write_dnslabel_vector(output_stream* os, dnslabel_vector_reference labels, s32 top);
ya_result output_stream_write_dnslabel_stack(output_stream* os, dnslabel_stack_reference labels, s32 top);
ya_result output_stream_decode_base64(output_stream* os, const char * string, u32 length);
ya_result output_stream_decode_base32(output_stream* os, const char * string, u32 length);
ya_result output_stream_decode_base32hex(output_stream* os, const char * string, u32 length);
ya_result output_stream_decode_base16(output_stream* os, const char * string, u32 length);
/* Found on typebitmap.h */
#define output_stream_write_type_bit_maps type_bit_maps_output_stream_write
output_stream *output_stream_alloc();
/**
* This tools allows a safer misuse (and detection) of closed streams
* It sets the stream to a sink that warns abouts its usage and for which every call that can fail fails.
*/
void output_stream_set_void(output_stream *stream);
ya_result output_stream_write_fully(output_stream *stream, const void *buffer_start, u32 len_start);
#ifdef __cplusplus
}
#endif
#endif /* _OUTPUT_STREAM_H */
|