Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/bind9/lwres
File: lwbuffer.h
/*
[0] Fix | Delete
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
[1] Fix | Delete
*
[2] Fix | Delete
* This Source Code Form is subject to the terms of the Mozilla Public
[3] Fix | Delete
* License, v. 2.0. If a copy of the MPL was not distributed with this
[4] Fix | Delete
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
[5] Fix | Delete
*
[6] Fix | Delete
* See the COPYRIGHT file distributed with this work for additional
[7] Fix | Delete
* information regarding copyright ownership.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
/*! \file lwres/lwbuffer.h
[11] Fix | Delete
*
[12] Fix | Delete
* A buffer is a region of memory, together with a set of related subregions.
[13] Fix | Delete
* Buffers are used for parsing and I/O operations.
[14] Fix | Delete
*
[15] Fix | Delete
* The 'used region' and the 'available' region are disjoint, and their
[16] Fix | Delete
* union is the buffer's region. The used region extends from the beginning
[17] Fix | Delete
* of the buffer region to the last used byte. The available region
[18] Fix | Delete
* extends from one byte greater than the last used byte to the end of the
[19] Fix | Delete
* buffer's region. The size of the used region can be changed using various
[20] Fix | Delete
* buffer commands. Initially, the used region is empty.
[21] Fix | Delete
*
[22] Fix | Delete
* The used region is further subdivided into two disjoint regions: the
[23] Fix | Delete
* 'consumed region' and the 'remaining region'. The union of these two
[24] Fix | Delete
* regions is the used region. The consumed region extends from the beginning
[25] Fix | Delete
* of the used region to the byte before the 'current' offset (if any). The
[26] Fix | Delete
* 'remaining' region the current pointer to the end of the used
[27] Fix | Delete
* region. The size of the consumed region can be changed using various
[28] Fix | Delete
* buffer commands. Initially, the consumed region is empty.
[29] Fix | Delete
*
[30] Fix | Delete
* The 'active region' is an (optional) subregion of the remaining region.
[31] Fix | Delete
* It extends from the current offset to an offset in the remaining region
[32] Fix | Delete
* that is selected with lwres_buffer_setactive(). Initially, the active
[33] Fix | Delete
* region is empty. If the current offset advances beyond the chosen offset,
[34] Fix | Delete
* the active region will also be empty.
[35] Fix | Delete
*
[36] Fix | Delete
* \verbatim
[37] Fix | Delete
* /----- used region -----\/-- available --\
[38] Fix | Delete
* +----------------------------------------+
[39] Fix | Delete
* | consumed | remaining | |
[40] Fix | Delete
* +----------------------------------------+
[41] Fix | Delete
* a b c d e
[42] Fix | Delete
*
[43] Fix | Delete
* a == base of buffer.
[44] Fix | Delete
* b == current pointer. Can be anywhere between a and d.
[45] Fix | Delete
* c == active pointer. Meaningful between b and d.
[46] Fix | Delete
* d == used pointer.
[47] Fix | Delete
* e == length of buffer.
[48] Fix | Delete
*
[49] Fix | Delete
* a-e == entire (length) of buffer.
[50] Fix | Delete
* a-d == used region.
[51] Fix | Delete
* a-b == consumed region.
[52] Fix | Delete
* b-d == remaining region.
[53] Fix | Delete
* b-c == optional active region.
[54] Fix | Delete
* \endverbatim
[55] Fix | Delete
*
[56] Fix | Delete
* The following invariants are maintained by all routines:
[57] Fix | Delete
*
[58] Fix | Delete
*\verbatim
[59] Fix | Delete
* length > 0
[60] Fix | Delete
*
[61] Fix | Delete
* base is a valid pointer to length bytes of memory
[62] Fix | Delete
*
[63] Fix | Delete
* 0 <= used <= length
[64] Fix | Delete
*
[65] Fix | Delete
* 0 <= current <= used
[66] Fix | Delete
*
[67] Fix | Delete
* 0 <= active <= used
[68] Fix | Delete
* (although active < current implies empty active region)
[69] Fix | Delete
*\endverbatim
[70] Fix | Delete
*
[71] Fix | Delete
* \li MP:
[72] Fix | Delete
* Buffers have no synchronization. Clients must ensure exclusive
[73] Fix | Delete
* access.
[74] Fix | Delete
*
[75] Fix | Delete
* \li Reliability:
[76] Fix | Delete
* No anticipated impact.
[77] Fix | Delete
*
[78] Fix | Delete
* \li Resources:
[79] Fix | Delete
* Memory: 1 pointer + 6 unsigned integers per buffer.
[80] Fix | Delete
*
[81] Fix | Delete
* \li Security:
[82] Fix | Delete
* No anticipated impact.
[83] Fix | Delete
*
[84] Fix | Delete
* \li Standards:
[85] Fix | Delete
* None.
[86] Fix | Delete
*/
[87] Fix | Delete
[88] Fix | Delete
#ifndef LWRES_LWBUFFER_H
[89] Fix | Delete
#define LWRES_LWBUFFER_H 1
[90] Fix | Delete
[91] Fix | Delete
/***
[92] Fix | Delete
*** Imports
[93] Fix | Delete
***/
[94] Fix | Delete
[95] Fix | Delete
#include <inttypes.h>
[96] Fix | Delete
[97] Fix | Delete
#include <lwres/lang.h>
[98] Fix | Delete
[99] Fix | Delete
LWRES_LANG_BEGINDECLS
[100] Fix | Delete
[101] Fix | Delete
/***
[102] Fix | Delete
*** Magic numbers
[103] Fix | Delete
***/
[104] Fix | Delete
#define LWRES_BUFFER_MAGIC 0x4275663fU /* Buf?. */
[105] Fix | Delete
[106] Fix | Delete
#define LWRES_BUFFER_VALID(b) ((b) != NULL && \
[107] Fix | Delete
(b)->magic == LWRES_BUFFER_MAGIC)
[108] Fix | Delete
[109] Fix | Delete
/*!
[110] Fix | Delete
* The following macros MUST be used only on valid buffers. It is the
[111] Fix | Delete
* caller's responsibility to ensure this by using the LWRES_BUFFER_VALID
[112] Fix | Delete
* check above, or by calling another lwres_buffer_*() function (rather than
[113] Fix | Delete
* another macro.)
[114] Fix | Delete
*/
[115] Fix | Delete
[116] Fix | Delete
/*!
[117] Fix | Delete
* Get the length of the used region of buffer "b"
[118] Fix | Delete
*/
[119] Fix | Delete
#define LWRES_BUFFER_USEDCOUNT(b) ((b)->used)
[120] Fix | Delete
[121] Fix | Delete
/*!
[122] Fix | Delete
* Get the length of the available region of buffer "b"
[123] Fix | Delete
*/
[124] Fix | Delete
#define LWRES_BUFFER_AVAILABLECOUNT(b) ((b)->length - (b)->used)
[125] Fix | Delete
[126] Fix | Delete
#define LWRES_BUFFER_REMAINING(b) ((b)->used - (b)->current)
[127] Fix | Delete
[128] Fix | Delete
/*!
[129] Fix | Delete
* Note that the buffer structure is public. This is principally so buffer
[130] Fix | Delete
* operations can be implemented using macros. Applications are strongly
[131] Fix | Delete
* discouraged from directly manipulating the structure.
[132] Fix | Delete
*/
[133] Fix | Delete
[134] Fix | Delete
typedef struct lwres_buffer lwres_buffer_t;
[135] Fix | Delete
/*!
[136] Fix | Delete
* Buffer data structure
[137] Fix | Delete
*/
[138] Fix | Delete
struct lwres_buffer {
[139] Fix | Delete
unsigned int magic;
[140] Fix | Delete
unsigned char *base;
[141] Fix | Delete
/* The following integers are byte offsets from 'base'. */
[142] Fix | Delete
unsigned int length;
[143] Fix | Delete
unsigned int used;
[144] Fix | Delete
unsigned int current;
[145] Fix | Delete
unsigned int active;
[146] Fix | Delete
};
[147] Fix | Delete
[148] Fix | Delete
/***
[149] Fix | Delete
*** Functions
[150] Fix | Delete
***/
[151] Fix | Delete
[152] Fix | Delete
void
[153] Fix | Delete
lwres_buffer_init(lwres_buffer_t *b, void *base, unsigned int length);
[154] Fix | Delete
/**<
[155] Fix | Delete
* Make 'b' refer to the 'length'-byte region starting at base.
[156] Fix | Delete
*
[157] Fix | Delete
* Requires:
[158] Fix | Delete
*
[159] Fix | Delete
* 'length' > 0
[160] Fix | Delete
*
[161] Fix | Delete
* 'base' is a pointer to a sequence of 'length' bytes.
[162] Fix | Delete
*
[163] Fix | Delete
*/
[164] Fix | Delete
[165] Fix | Delete
void
[166] Fix | Delete
lwres_buffer_invalidate(lwres_buffer_t *b);
[167] Fix | Delete
/**<
[168] Fix | Delete
* Make 'b' an invalid buffer.
[169] Fix | Delete
*
[170] Fix | Delete
* Requires:
[171] Fix | Delete
* 'b' is a valid buffer.
[172] Fix | Delete
*
[173] Fix | Delete
* Ensures:
[174] Fix | Delete
* If assertion checking is enabled, future attempts to use 'b' without
[175] Fix | Delete
* calling lwres_buffer_init() on it will cause an assertion failure.
[176] Fix | Delete
*/
[177] Fix | Delete
[178] Fix | Delete
void
[179] Fix | Delete
lwres_buffer_add(lwres_buffer_t *b, unsigned int n);
[180] Fix | Delete
/**<
[181] Fix | Delete
* Increase the 'used' region of 'b' by 'n' bytes.
[182] Fix | Delete
*
[183] Fix | Delete
* Requires:
[184] Fix | Delete
*
[185] Fix | Delete
* 'b' is a valid buffer
[186] Fix | Delete
*
[187] Fix | Delete
* used + n <= length
[188] Fix | Delete
*
[189] Fix | Delete
*/
[190] Fix | Delete
[191] Fix | Delete
void
[192] Fix | Delete
lwres_buffer_subtract(lwres_buffer_t *b, unsigned int n);
[193] Fix | Delete
/**<
[194] Fix | Delete
* Decrease the 'used' region of 'b' by 'n' bytes.
[195] Fix | Delete
*
[196] Fix | Delete
* Requires:
[197] Fix | Delete
*
[198] Fix | Delete
* 'b' is a valid buffer
[199] Fix | Delete
*
[200] Fix | Delete
* used >= n
[201] Fix | Delete
*
[202] Fix | Delete
*/
[203] Fix | Delete
[204] Fix | Delete
void
[205] Fix | Delete
lwres_buffer_clear(lwres_buffer_t *b);
[206] Fix | Delete
/**<
[207] Fix | Delete
* Make the used region empty.
[208] Fix | Delete
*
[209] Fix | Delete
* Requires:
[210] Fix | Delete
*
[211] Fix | Delete
* 'b' is a valid buffer
[212] Fix | Delete
*
[213] Fix | Delete
* Ensures:
[214] Fix | Delete
*
[215] Fix | Delete
* used = 0
[216] Fix | Delete
*
[217] Fix | Delete
*/
[218] Fix | Delete
[219] Fix | Delete
[220] Fix | Delete
void
[221] Fix | Delete
lwres_buffer_first(lwres_buffer_t *b);
[222] Fix | Delete
/**<
[223] Fix | Delete
* Make the consumed region empty.
[224] Fix | Delete
*
[225] Fix | Delete
* Requires:
[226] Fix | Delete
*
[227] Fix | Delete
* 'b' is a valid buffer
[228] Fix | Delete
*
[229] Fix | Delete
* Ensures:
[230] Fix | Delete
*
[231] Fix | Delete
* current == 0
[232] Fix | Delete
*
[233] Fix | Delete
*/
[234] Fix | Delete
[235] Fix | Delete
void
[236] Fix | Delete
lwres_buffer_forward(lwres_buffer_t *b, unsigned int n);
[237] Fix | Delete
/**<
[238] Fix | Delete
* Increase the 'consumed' region of 'b' by 'n' bytes.
[239] Fix | Delete
*
[240] Fix | Delete
* Requires:
[241] Fix | Delete
*
[242] Fix | Delete
* 'b' is a valid buffer
[243] Fix | Delete
*
[244] Fix | Delete
* current + n <= used
[245] Fix | Delete
*
[246] Fix | Delete
*/
[247] Fix | Delete
[248] Fix | Delete
void
[249] Fix | Delete
lwres_buffer_back(lwres_buffer_t *b, unsigned int n);
[250] Fix | Delete
/**<
[251] Fix | Delete
* Decrease the 'consumed' region of 'b' by 'n' bytes.
[252] Fix | Delete
*
[253] Fix | Delete
* Requires:
[254] Fix | Delete
*
[255] Fix | Delete
* 'b' is a valid buffer
[256] Fix | Delete
*
[257] Fix | Delete
* n <= current
[258] Fix | Delete
*
[259] Fix | Delete
*/
[260] Fix | Delete
[261] Fix | Delete
uint8_t
[262] Fix | Delete
lwres_buffer_getuint8(lwres_buffer_t *b);
[263] Fix | Delete
/**<
[264] Fix | Delete
* Read an unsigned 8-bit integer from 'b' and return it.
[265] Fix | Delete
*
[266] Fix | Delete
* Requires:
[267] Fix | Delete
*
[268] Fix | Delete
* 'b' is a valid buffer.
[269] Fix | Delete
*
[270] Fix | Delete
* The length of the available region of 'b' is at least 1.
[271] Fix | Delete
*
[272] Fix | Delete
* Ensures:
[273] Fix | Delete
*
[274] Fix | Delete
* The current pointer in 'b' is advanced by 1.
[275] Fix | Delete
*
[276] Fix | Delete
* Returns:
[277] Fix | Delete
*
[278] Fix | Delete
* A 8-bit unsigned integer.
[279] Fix | Delete
*/
[280] Fix | Delete
[281] Fix | Delete
void
[282] Fix | Delete
lwres_buffer_putuint8(lwres_buffer_t *b, uint8_t val);
[283] Fix | Delete
/**<
[284] Fix | Delete
* Store an unsigned 8-bit integer from 'val' into 'b'.
[285] Fix | Delete
*
[286] Fix | Delete
* Requires:
[287] Fix | Delete
* 'b' is a valid buffer.
[288] Fix | Delete
*
[289] Fix | Delete
* The length of the unused region of 'b' is at least 1.
[290] Fix | Delete
*
[291] Fix | Delete
* Ensures:
[292] Fix | Delete
* The used pointer in 'b' is advanced by 1.
[293] Fix | Delete
*/
[294] Fix | Delete
[295] Fix | Delete
uint16_t
[296] Fix | Delete
lwres_buffer_getuint16(lwres_buffer_t *b);
[297] Fix | Delete
/**<
[298] Fix | Delete
* Read an unsigned 16-bit integer in network byte order from 'b', convert
[299] Fix | Delete
* it to host byte order, and return it.
[300] Fix | Delete
*
[301] Fix | Delete
* Requires:
[302] Fix | Delete
*
[303] Fix | Delete
* 'b' is a valid buffer.
[304] Fix | Delete
*
[305] Fix | Delete
* The length of the available region of 'b' is at least 2.
[306] Fix | Delete
*
[307] Fix | Delete
* Ensures:
[308] Fix | Delete
*
[309] Fix | Delete
* The current pointer in 'b' is advanced by 2.
[310] Fix | Delete
*
[311] Fix | Delete
* Returns:
[312] Fix | Delete
*
[313] Fix | Delete
* A 16-bit unsigned integer.
[314] Fix | Delete
*/
[315] Fix | Delete
[316] Fix | Delete
void
[317] Fix | Delete
lwres_buffer_putuint16(lwres_buffer_t *b, uint16_t val);
[318] Fix | Delete
/**<
[319] Fix | Delete
* Store an unsigned 16-bit integer in host byte order from 'val'
[320] Fix | Delete
* into 'b' in network byte order.
[321] Fix | Delete
*
[322] Fix | Delete
* Requires:
[323] Fix | Delete
* 'b' is a valid buffer.
[324] Fix | Delete
*
[325] Fix | Delete
* The length of the unused region of 'b' is at least 2.
[326] Fix | Delete
*
[327] Fix | Delete
* Ensures:
[328] Fix | Delete
* The used pointer in 'b' is advanced by 2.
[329] Fix | Delete
*/
[330] Fix | Delete
[331] Fix | Delete
uint32_t
[332] Fix | Delete
lwres_buffer_getuint32(lwres_buffer_t *b);
[333] Fix | Delete
/**<
[334] Fix | Delete
* Read an unsigned 32-bit integer in network byte order from 'b', convert
[335] Fix | Delete
* it to host byte order, and return it.
[336] Fix | Delete
*
[337] Fix | Delete
* Requires:
[338] Fix | Delete
*
[339] Fix | Delete
* 'b' is a valid buffer.
[340] Fix | Delete
*
[341] Fix | Delete
* The length of the available region of 'b' is at least 2.
[342] Fix | Delete
*
[343] Fix | Delete
* Ensures:
[344] Fix | Delete
*
[345] Fix | Delete
* The current pointer in 'b' is advanced by 2.
[346] Fix | Delete
*
[347] Fix | Delete
* Returns:
[348] Fix | Delete
*
[349] Fix | Delete
* A 32-bit unsigned integer.
[350] Fix | Delete
*/
[351] Fix | Delete
[352] Fix | Delete
void
[353] Fix | Delete
lwres_buffer_putuint32(lwres_buffer_t *b, uint32_t val);
[354] Fix | Delete
/**<
[355] Fix | Delete
* Store an unsigned 32-bit integer in host byte order from 'val'
[356] Fix | Delete
* into 'b' in network byte order.
[357] Fix | Delete
*
[358] Fix | Delete
* Requires:
[359] Fix | Delete
* 'b' is a valid buffer.
[360] Fix | Delete
*
[361] Fix | Delete
* The length of the unused region of 'b' is at least 4.
[362] Fix | Delete
*
[363] Fix | Delete
* Ensures:
[364] Fix | Delete
* The used pointer in 'b' is advanced by 4.
[365] Fix | Delete
*/
[366] Fix | Delete
[367] Fix | Delete
void
[368] Fix | Delete
lwres_buffer_putmem(lwres_buffer_t *b, const unsigned char *base,
[369] Fix | Delete
unsigned int length);
[370] Fix | Delete
/**<
[371] Fix | Delete
* Copy 'length' bytes of memory at 'base' into 'b'.
[372] Fix | Delete
*
[373] Fix | Delete
* Requires:
[374] Fix | Delete
* 'b' is a valid buffer.
[375] Fix | Delete
*
[376] Fix | Delete
* 'base' points to 'length' bytes of valid memory.
[377] Fix | Delete
*
[378] Fix | Delete
*/
[379] Fix | Delete
[380] Fix | Delete
void
[381] Fix | Delete
lwres_buffer_getmem(lwres_buffer_t *b, unsigned char *base,
[382] Fix | Delete
unsigned int length);
[383] Fix | Delete
/**<
[384] Fix | Delete
* Copy 'length' bytes of memory from 'b' into 'base'.
[385] Fix | Delete
*
[386] Fix | Delete
* Requires:
[387] Fix | Delete
* 'b' is a valid buffer.
[388] Fix | Delete
*
[389] Fix | Delete
* 'base' points to at least 'length' bytes of valid memory.
[390] Fix | Delete
*
[391] Fix | Delete
* 'b' have at least 'length' bytes remaining.
[392] Fix | Delete
*/
[393] Fix | Delete
[394] Fix | Delete
LWRES_LANG_ENDDECLS
[395] Fix | Delete
[396] Fix | Delete
#endif /* LWRES_LWBUFFER_H */
[397] Fix | Delete
[398] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function