37 _endian.
ui = 0x11223344;
38 if (_endian.
uc[0] == 0x44)
41 const char *
in = (
const char *)inp;
42 char *
out = (
char *)outp;
58 _endian.
ui = 0x11223344;
59 if (_endian.
uc[0] == 0x44)
62 const char *
in = (
const char *)inp;
63 char *
out = (
char *)outp;
74 _endian.
ui = 0x11223344;
75 if (_endian.
uc[0] == 0x11)
78 const char *
in = (
const char *)inp;
79 char *
out = (
char *)outp;
95 _endian.
ui = 0x11223344;
96 if (_endian.
uc[0] == 0x11)
99 const char *
in = (
const char *)inp;
100 char *
out = (
char *)outp;
121 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
122 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
123 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
124 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
125 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
126 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
127 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
128 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
143 static int isLegalUTF8(
const unsigned char *source,
int length ) {
145 const unsigned char *srcptr = source + length;
151 if ( ( a = ( *--srcptr ) ) < 0x80 || a > 0xBF )
return 0;
153 if ( ( a = ( *--srcptr ) ) < 0x80 || a > 0xBF )
return 0;
155 if ( ( a = ( *--srcptr ) ) > 0xBF )
return 0;
159 if ( a < 0xA0 )
return 0;
162 if ( a < 0x90 )
return 0;
165 if ( a > 0x8F )
return 0;
168 if ( a < 0x80 )
return 0;
171 if ( *source >= 0x80 && *source < 0xC2 )
return 0;
172 if ( *source > 0xF4 )
return 0;
182 if(
string[1] ==
'r' &&
string[2] ==
'e' &&
string[3] ==
'f' )
185 else if( length >= 3 ) {
186 if(
string[1] ==
'i' &&
string[2] ==
'd' )
188 else if(
string[1] ==
'd' &&
string[2] ==
'b' )
196 const size_t length,
const char check_utf8,
const char check_dot,
197 const char check_dollar ) {
200 int sequence_length = 1;
202 if( check_dollar &&
string[0] ==
'$' ) {
207 while ( position < length ) {
208 if ( check_dot && *(
string + position ) ==
'.' ) {
214 if ( ( position + sequence_length ) > length ) {
218 if ( !
isLegalUTF8(
string + position, sequence_length ) ) {
223 position += sequence_length;
231 const size_t length ) {
237 const size_t length ) {
247 "0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
248 "10",
"11",
"12",
"13",
"14",
"15",
"16",
"17",
"18",
"19",
249 "20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
250 "30",
"31",
"32",
"33",
"34",
"35",
"36",
"37",
"38",
"39",
251 "40",
"41",
"42",
"43",
"44",
"45",
"46",
"47",
"48",
"49",
252 "50",
"51",
"52",
"53",
"54",
"55",
"56",
"57",
"58",
"59",
253 "60",
"61",
"62",
"63",
"64",
"65",
"66",
"67",
"68",
"69",
254 "70",
"71",
"72",
"73",
"74",
"75",
"76",
"77",
"78",
"79",
255 "80",
"81",
"82",
"83",
"84",
"85",
"86",
"87",
"88",
"89",
256 "90",
"91",
"92",
"93",
"94",
"95",
"96",
"97",
"98",
"99",
258 "100",
"101",
"102",
"103",
"104",
"105",
"106",
"107",
"108",
"109",
259 "110",
"111",
"112",
"113",
"114",
"115",
"116",
"117",
"118",
"119",
260 "120",
"121",
"122",
"123",
"124",
"125",
"126",
"127",
"128",
"129",
261 "130",
"131",
"132",
"133",
"134",
"135",
"136",
"137",
"138",
"139",
262 "140",
"141",
"142",
"143",
"144",
"145",
"146",
"147",
"148",
"149",
263 "150",
"151",
"152",
"153",
"154",
"155",
"156",
"157",
"158",
"159",
264 "160",
"161",
"162",
"163",
"164",
"165",
"166",
"167",
"168",
"169",
265 "170",
"171",
"172",
"173",
"174",
"175",
"176",
"177",
"178",
"179",
266 "180",
"181",
"182",
"183",
"184",
"185",
"186",
"187",
"188",
"189",
267 "190",
"191",
"192",
"193",
"194",
"195",
"196",
"197",
"198",
"199",
269 "200",
"201",
"202",
"203",
"204",
"205",
"206",
"207",
"208",
"209",
270 "210",
"211",
"212",
"213",
"214",
"215",
"216",
"217",
"218",
"219",
271 "220",
"221",
"222",
"223",
"224",
"225",
"226",
"227",
"228",
"229",
272 "230",
"231",
"232",
"233",
"234",
"235",
"236",
"237",
"238",
"239",
273 "240",
"241",
"242",
"243",
"244",
"245",
"246",
"247",
"248",
"249",
274 "250",
"251",
"252",
"253",
"254",
"255",
"256",
"257",
"258",
"259",
275 "260",
"261",
"262",
"263",
"264",
"265",
"266",
"267",
"268",
"269",
276 "270",
"271",
"272",
"273",
"274",
"275",
"276",
"277",
"278",
"279",
277 "280",
"281",
"282",
"283",
"284",
"285",
"286",
"287",
"288",
"289",
278 "290",
"291",
"292",
"293",
"294",
"295",
"296",
"297",
"298",
"299",
280 "300",
"301",
"302",
"303",
"304",
"305",
"306",
"307",
"308",
"309",
281 "310",
"311",
"312",
"313",
"314",
"315",
"316",
"317",
"318",
"319",
282 "320",
"321",
"322",
"323",
"324",
"325",
"326",
"327",
"328",
"329",
283 "330",
"331",
"332",
"333",
"334",
"335",
"336",
"337",
"338",
"339",
284 "340",
"341",
"342",
"343",
"344",
"345",
"346",
"347",
"348",
"349",
285 "350",
"351",
"352",
"353",
"354",
"355",
"356",
"357",
"358",
"359",
286 "360",
"361",
"362",
"363",
"364",
"365",
"366",
"367",
"368",
"369",
287 "370",
"371",
"372",
"373",
"374",
"375",
"376",
"377",
"378",
"379",
288 "380",
"381",
"382",
"383",
"384",
"385",
"386",
"387",
"388",
"389",
289 "390",
"391",
"392",
"393",
"394",
"395",
"396",
"397",
"398",
"399",
291 "400",
"401",
"402",
"403",
"404",
"405",
"406",
"407",
"408",
"409",
292 "410",
"411",
"412",
"413",
"414",
"415",
"416",
"417",
"418",
"419",
293 "420",
"421",
"422",
"423",
"424",
"425",
"426",
"427",
"428",
"429",
294 "430",
"431",
"432",
"433",
"434",
"435",
"436",
"437",
"438",
"439",
295 "440",
"441",
"442",
"443",
"444",
"445",
"446",
"447",
"448",
"449",
296 "450",
"451",
"452",
"453",
"454",
"455",
"456",
"457",
"458",
"459",
297 "460",
"461",
"462",
"463",
"464",
"465",
"466",
"467",
"468",
"469",
298 "470",
"471",
"472",
"473",
"474",
"475",
"476",
"477",
"478",
"479",
299 "480",
"481",
"482",
"483",
"484",
"485",
"486",
"487",
"488",
"489",
300 "490",
"491",
"492",
"493",
"494",
"495",
"496",
"497",
"498",
"499",
302 "500",
"501",
"502",
"503",
"504",
"505",
"506",
"507",
"508",
"509",
303 "510",
"511",
"512",
"513",
"514",
"515",
"516",
"517",
"518",
"519",
304 "520",
"521",
"522",
"523",
"524",
"525",
"526",
"527",
"528",
"529",
305 "530",
"531",
"532",
"533",
"534",
"535",
"536",
"537",
"538",
"539",
306 "540",
"541",
"542",
"543",
"544",
"545",
"546",
"547",
"548",
"549",
307 "550",
"551",
"552",
"553",
"554",
"555",
"556",
"557",
"558",
"559",
308 "560",
"561",
"562",
"563",
"564",
"565",
"566",
"567",
"568",
"569",
309 "570",
"571",
"572",
"573",
"574",
"575",
"576",
"577",
"578",
"579",
310 "580",
"581",
"582",
"583",
"584",
"585",
"586",
"587",
"588",
"589",
311 "590",
"591",
"592",
"593",
"594",
"595",
"596",
"597",
"598",
"599",
313 "600",
"601",
"602",
"603",
"604",
"605",
"606",
"607",
"608",
"609",
314 "610",
"611",
"612",
"613",
"614",
"615",
"616",
"617",
"618",
"619",
315 "620",
"621",
"622",
"623",
"624",
"625",
"626",
"627",
"628",
"629",
316 "630",
"631",
"632",
"633",
"634",
"635",
"636",
"637",
"638",
"639",
317 "640",
"641",
"642",
"643",
"644",
"645",
"646",
"647",
"648",
"649",
318 "650",
"651",
"652",
"653",
"654",
"655",
"656",
"657",
"658",
"659",
319 "660",
"661",
"662",
"663",
"664",
"665",
"666",
"667",
"668",
"669",
320 "670",
"671",
"672",
"673",
"674",
"675",
"676",
"677",
"678",
"679",
321 "680",
"681",
"682",
"683",
"684",
"685",
"686",
"687",
"688",
"689",
322 "690",
"691",
"692",
"693",
"694",
"695",
"696",
"697",
"698",
"699",
324 "700",
"701",
"702",
"703",
"704",
"705",
"706",
"707",
"708",
"709",
325 "710",
"711",
"712",
"713",
"714",
"715",
"716",
"717",
"718",
"719",
326 "720",
"721",
"722",
"723",
"724",
"725",
"726",
"727",
"728",
"729",
327 "730",
"731",
"732",
"733",
"734",
"735",
"736",
"737",
"738",
"739",
328 "740",
"741",
"742",
"743",
"744",
"745",
"746",
"747",
"748",
"749",
329 "750",
"751",
"752",
"753",
"754",
"755",
"756",
"757",
"758",
"759",
330 "760",
"761",
"762",
"763",
"764",
"765",
"766",
"767",
"768",
"769",
331 "770",
"771",
"772",
"773",
"774",
"775",
"776",
"777",
"778",
"779",
332 "780",
"781",
"782",
"783",
"784",
"785",
"786",
"787",
"788",
"789",
333 "790",
"791",
"792",
"793",
"794",
"795",
"796",
"797",
"798",
"799",
335 "800",
"801",
"802",
"803",
"804",
"805",
"806",
"807",
"808",
"809",
336 "810",
"811",
"812",
"813",
"814",
"815",
"816",
"817",
"818",
"819",
337 "820",
"821",
"822",
"823",
"824",
"825",
"826",
"827",
"828",
"829",
338 "830",
"831",
"832",
"833",
"834",
"835",
"836",
"837",
"838",
"839",
339 "840",
"841",
"842",
"843",
"844",
"845",
"846",
"847",
"848",
"849",
340 "850",
"851",
"852",
"853",
"854",
"855",
"856",
"857",
"858",
"859",
341 "860",
"861",
"862",
"863",
"864",
"865",
"866",
"867",
"868",
"869",
342 "870",
"871",
"872",
"873",
"874",
"875",
"876",
"877",
"878",
"879",
343 "880",
"881",
"882",
"883",
"884",
"885",
"886",
"887",
"888",
"889",
344 "890",
"891",
"892",
"893",
"894",
"895",
"896",
"897",
"898",
"899",
346 "900",
"901",
"902",
"903",
"904",
"905",
"906",
"907",
"908",
"909",
347 "910",
"911",
"912",
"913",
"914",
"915",
"916",
"917",
"918",
"919",
348 "920",
"921",
"922",
"923",
"924",
"925",
"926",
"927",
"928",
"929",
349 "930",
"931",
"932",
"933",
"934",
"935",
"936",
"937",
"938",
"939",
350 "940",
"941",
"942",
"943",
"944",
"945",
"946",
"947",
"948",
"949",
351 "950",
"951",
"952",
"953",
"954",
"955",
"956",
"957",
"958",
"959",
352 "960",
"961",
"962",
"963",
"964",
"965",
"966",
"967",
"968",
"969",
353 "970",
"971",
"972",
"973",
"974",
"975",
"976",
"977",
"978",
"979",
354 "980",
"981",
"982",
"983",
"984",
"985",
"986",
"987",
"988",
"989",
355 "990",
"991",
"992",
"993",
"994",
"995",
"996",
"997",
"998",
"999",
364 void *( *bson_malloc_func )( size_t ) = malloc;
365 void *( *bson_realloc_func )(
void *, size_t ) = realloc;
390 memset(b, 0,
sizeof(
bson) -
sizeof(b->
stack));
394 return (
bson* )bson_malloc(
sizeof(
bson ) );
420 memcpy( b->
data, data, dataSize );
432 return &shared_empty;
443 if ( ! b || ! b->
data )
459 return (
const char *)b->
data;
463 if (hex >=
'0' && hex <=
'9')
465 else if (hex >=
'A' && hex <=
'F')
466 return (hex -
'A' + 10);
467 else if (hex >=
'a' && hex <=
'f')
468 return (hex -
'a' + 10);
475 for ( i=0; i<12; i++ ) {
481 static const char hex[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'};
483 for ( i=0; i<12; i++ ) {
484 str[2*
i] = hex[( oid->
bytes[
i] & 0xf0 ) >> 4];
485 str[2*i + 1] = hex[ oid->
bytes[
i] & 0x0f ];
490 MONGO_EXPORT void bson_set_oid_fuzz(
int ( *func )(
void ) ) {
494 MONGO_EXPORT void bson_set_oid_inc(
int ( *func )(
void ) ) {
502 time_t t =
time( NULL );
531 bson_print_raw( b->
data , 0 );
541 bson_iterator_from_buffer( &i, data );
543 while ( bson_iterator_next( &i ) ) {
547 key = bson_iterator_key( &i );
549 for ( temp=0; temp<=
depth; temp++ )
560 bson_printf(
"SYMBOL: %s" , bson_iterator_string( &i ) );
563 bson_oid_to_string( bson_iterator_oid( &i ), oidhex );
567 bson_printf(
"%s" , bson_iterator_bool( &i ) ?
"true" :
"false" );
570 bson_printf(
"%ld" , (
long int )bson_iterator_date( &i ) );
582 bson_printf(
"BSON_REGEX: %s", bson_iterator_regex( &i ) );
585 bson_printf(
"BSON_CODE: %s", bson_iterator_code( &i ) );
588 bson_printf(
"BSON_CODE_W_SCOPE: %s", bson_iterator_code( &i ) );
589 bson_iterator_code_scope_init( &i, &scope, 0 );
591 bson_print( &scope );
592 bson_destroy( &scope );
598 bson_printf(
"%lld" , ( uint64_t )bson_iterator_long( &i ) );
601 ts = bson_iterator_timestamp( &i );
607 bson_print_raw( bson_iterator_value( &i ) , depth + 1 );
639 bson_iterator_init( it, (
bson *)obj );
640 while( bson_iterator_next( it ) ) {
641 if ( strcmp( name, bson_iterator_key( it ) ) == 0 )
644 return bson_iterator_type( it );
659 switch ( bson_iterator_type( i ) ) {
700 const char *s = bson_iterator_value( i );
709 char msg[] =
"unknown type: 000000000000";
716 i->
cur += 1 + strlen( i->
cur + 1 ) + 1 + ds;
731 const char *t = i->
cur + 1;
732 t += strlen( t ) + 1;
757 return bson_iterator_value( i )[0];
761 return (
bson_oid_t * )bson_iterator_value( i );
765 switch ( bson_iterator_type( i ) ) {
778 switch ( bson_iterator_type( i ) ) {
791 switch ( bson_iterator_type( i ) ) {
826 switch ( bson_iterator_type( i ) ) {
844 switch ( bson_iterator_type( i ) ) {
847 return bson_iterator_value( i ) + 4;
858 switch ( bson_iterator_type( i ) ) {
861 return bson_iterator_value( i ) + 4;
863 return bson_iterator_value( i ) + 8;
872 const char * scopeData = bson_iterator_value( i )+8+codeLen;
879 bson_init_empty( scope );
888 return bson_iterator_date( i ) / 1000;
898 return bson_iterator_value( i )[4];
903 ? bson_iterator_value( i ) + 9
904 : bson_iterator_value( i ) + 5;
908 return bson_iterator_value( i );
912 const char *p = bson_iterator_value( i );
913 return p + strlen( p ) + 1;
918 const char *data = bson_iterator_value( i );
926 bson_iterator_from_buffer( sub, bson_iterator_value( i ) );
934 memset( b, 0,
sizeof(
bson ) );
945 char * data = (
char *) bson_malloc( size );
971 size_t *new_stack = (
size_t * ) bson_malloc( 2 *
sizeof( b->
stack ) );
1001 memcpy( b->
cur , data , len );
1022 char *orig = b->
data;
1025 if ( pos + bytesNeeded <= (
size_t) b->
dataSize )
1028 new_size = (int) ( 1.5 * ( b->
dataSize + bytesNeeded ) );
1030 if( new_size < b->dataSize ) {
1031 if( ( b->
dataSize + bytesNeeded ) < INT_MAX )
1079 bson_free( b->
data );
1097 const size_t len = strlen( name ) + 1;
1122 MONGO_EXPORT int bson_append_int(
bson *b,
const char *name,
const int i ) {
1129 MONGO_EXPORT int bson_append_long(
bson *b,
const char *name,
const int64_t i ) {
1136 MONGO_EXPORT int bson_append_double(
bson *b,
const char *name,
const double d ) {
1177 size_t sl = len + 1;
1178 if ( sl > INT32_MAX ) {
1194 MONGO_EXPORT int bson_append_string(
bson *b,
const char *name,
const char *value ) {
1198 MONGO_EXPORT int bson_append_symbol(
bson *b,
const char *name,
const char *value ) {
1202 MONGO_EXPORT int bson_append_code(
bson *b,
const char *name,
const char *value ) {
1206 MONGO_EXPORT int bson_append_string_n(
bson *b,
const char *name,
const char *value,
size_t len ) {
1210 MONGO_EXPORT int bson_append_symbol_n(
bson *b,
const char *name,
const char *value,
size_t len ) {
1214 MONGO_EXPORT int bson_append_code_n(
bson *b,
const char *name,
const char *value,
size_t len ) {
1219 const char *
code,
size_t len,
const bson *scope ) {
1224 size = 4 + 4 + sl + bson_size( scope );
1225 if ( size > (
size_t)INT32_MAX ) {
1238 MONGO_EXPORT int bson_append_code_w_scope(
bson *b,
const char *name,
const char *code,
const bson *scope ) {
1239 return bson_append_code_w_scope_n( b, name, code, strlen ( code ), scope );
1242 MONGO_EXPORT int bson_append_binary(
bson *b,
const char *name,
char type,
const char *str,
size_t len ) {
1244 size_t subtwolen = len + 4;
1271 bson_oid_gen( &oid );
1272 return bson_append_oid( b, name, &oid );
1276 const size_t plen = strlen( pattern )+1;
1277 const size_t olen = strlen( opts )+1;
1299 bson_iterator_next( &next );
1300 size = next.
cur - elem->
cur;
1302 if ( name_or_null == NULL ) {
1308 size_t data_size = size - 2 - strlen( bson_iterator_key( elem ) );
1311 bson_append( b, bson_iterator_value( elem ), data_size );
1326 MONGO_EXPORT int bson_append_timestamp2( bson *b,
const char *name,
int time,
int increment ) {
1340 MONGO_EXPORT int bson_append_time_t( bson *b,
const char *name, time_t
secs ) {
1341 return bson_append_date( b, name, (
bson_date_t )secs * 1000 );
1344 MONGO_EXPORT int bson_append_start_object( bson *b,
const char *name ) {
1352 MONGO_EXPORT int bson_append_start_array( bson *b,
const char *name ) {
1360 MONGO_EXPORT int bson_append_finish_object( bson *b ) {
1369 if ( b->
cur - start >= INT32_MAX ) {
1373 i = ( int )( b->
cur - start );
1379 MONGO_EXPORT double bson_int64_to_double( int64_t i64 ) {
1384 return bson_append_finish_object( b );
1418 va_start( ap, format );
1419 #ifndef R_SAFETY_NET
1420 ret = vfprintf( stderr, format, ap );
1446 if ( err_handler ) {
1449 #ifndef R_SAFETY_NET
1461 memcpy( str, bson_numstrs[i], 4 );
1467 const char *in = (
const char * )inp;
1468 char *out = (
char * )outp;
1482 const char *in = (
const char * )inp;
1483 char *out = (
char * )outp;
static void bson_append32_as_int(bson *b, int data)
const char const double d
int bson_init_unfinished_data(bson *b, char *data, int dataSize, bson_bool_t ownsData)
Initialize a BSON object for building, using the provided char* of the given size.
static int isLegalUTF8(const unsigned char *source, int length)
const char const char size_t len
const char bson_timestamp_t * ts
static int bson_string_is_db_ref(const unsigned char *string, const size_t length)
A key or a string is not valid UTF-8.
int err
Bitfield representing errors or warnings on this buffer.
static char bson_shared_empty_data[]
bson_printf_func bson_printf
bson_sprintf_func bson_sprintf
void bson_numstr(char *str, int i)
int bson_iterator_string_len(const bson_iterator *i)
Get the string length of the BSON object currently pointed to by the iterator.
Trying to expand a BSON object which does not own its data block.
int bson_init_size(bson *b, int size)
Initialize a BSON object for building and allocate a data buffer of a given size. ...
static int _bson_errprintf(const char *,...)
const char bson_date_t millis
static int bson_finished_data_size(const char *data)
bson bson_bool_t copyData
double bson_iterator_double_raw(const bson_iterator *i)
Get the double value of the BSON object currently pointed to by the iterator.
int bson_init_finished_data_with_copy(bson *b, const char *data)
Initialize a BSON object for reading and copy finalized BSON data from the provided char*...
int dataSize
The number of bytes allocated to char *data.
static void _bson_zero(bson *b)
char * data
Pointer to a block of data in this BSON object.
Trying bson_append_finish_object() and not in sub.
static int(* oid_fuzz_func)(void)
void bson_fatal(int ok)
Exit fatally.
static int bson_check_field_name(bson *b, const char *string, const size_t length)
static const char trailingBytesForUTF8[256]
static void bson_append_byte(bson *b, char c)
void *(* bson_realloc_func)(void *, size_t)
static void bson_append32(bson *b, const void *data)
static int(* oid_inc_func)(void)
void bson_big_endian64(void *outp, const void *inp)
bson_printf_func bson_errprintf
static int bson_append_estart(bson *b, int type, const char *name, const size_t dataSize)
const char const bson_oid_t * oid
const char const bson * data
bson_bool_t ownsData
Whether destroying this object will deallocate its data block.
int(* bson_printf_func)(const char *,...)
static int bson_append_string_base(bson *b, const char *name, const char *value, size_t len, bson_type type)
int(* bson_fprintf_func)(FILE *, const char *,...)
static int bson_check_string(bson *b, const char *string, const size_t length)
static bson_err_handler err_handler
static size_t _bson_position(const bson *b)
static char hexbyte(char hex)
void(* bson_free_func)(void *)
static const int initialBufferSize
int stackPos
Index of current stack position.
void bson_little_endian32(void *outp, const void *inp)
void bson_builder_error(bson *b)
This method is invoked when a non-fatal bson error is encountered.
int bson_iterator_int_raw(const bson_iterator *i)
Get the int value of the BSON object currently pointed to by the iterator.
bson_bool_t bson_iterator_bool_raw(const bson_iterator *i)
Get the bson_bool_t value of the BSON object currently pointed to by the iterator.
size_t stack[32]
A stack used to keep track of nested BSON elements.
static void bson_append(bson *b, const void *data, size_t len)
const char * name_or_null
void bson_big_endian32(void *outp, const void *inp)
void bson_fatal_msg(int ok, const char *msg)
Exit fatally with an error message.
Warning: key starts with '$' character.
bson_fprintf_func bson_fprintf
const char const char const char * opts
int stackSize
Number of elements in the current stack.
bson_bool_t finished
When finished, the BSON object can no longer be modified.
const char int int increment
const char const bson * key
const char const bson const bson bson * out
const char const char size_t size
const char bson_numstrs[1000][4]
void(* bson_err_handler)(const char *errmsg)
int bson_ensure_space(bson *b, const size_t bytesNeeded)
Grow a bson object.
static int bson_validate_string(bson *b, const unsigned char *string, const size_t length, const char check_utf8, const char check_dot, const char check_dollar)
const char const char * code
static int _bson_append_grow_stack(bson *b)
void bson_little_endian64(void *outp, const void *inp)
const char const char * pattern
void *(* bson_malloc_func)(size_t)
static void bson_append64(bson *b, const void *data)
int64_t bson_iterator_long_raw(const bson_iterator *i)
Get the long value of the BSON object currently pointed to by the iterator.
Trying to create a BSON object larger than INT_MAX.
int bson_init_finished_data(bson *b, char *data, bson_bool_t ownsData)
Initialize a BSON object for reading and set its data pointer to the provided char*.
int(* bson_sprintf_func)(char *, const char *,...)
size_t * stackPtr
Pointer to the current stack.
const char const bson_iterator * elem
char * cur
Pointer to the current position.
void * bson_realloc(void *ptr, size_t size)
Changes the size of allocated memory and checks return value, exiting fatally if realloc() fails...
Trying to modify a finished BSON object.