@@ -111,10 +111,10 @@ static const char Pad64 = '=';
111
111
*/
112
112
113
113
int
114
- b64_ntop (uint8_t const * src ,
115
- size_t srclength ,
116
- char * target ,
117
- size_t targsize )
114
+ mongoc_b64_ntop (uint8_t const * src ,
115
+ size_t srclength ,
116
+ char * target ,
117
+ size_t targsize )
118
118
{
119
119
size_t datalength = 0 ;
120
120
uint8_t input [3 ];
@@ -251,49 +251,49 @@ b64_ntop (uint8_t const *src,
251
251
it returns the number of data bytes stored at the target, or -1 on error.
252
252
*/
253
253
254
- static int b64rmap_initialized = 0 ;
255
- static uint8_t b64rmap [256 ];
254
+ static int mongoc_b64rmap_initialized = 0 ;
255
+ static uint8_t mongoc_b64rmap [256 ];
256
256
257
- static const uint8_t b64rmap_special = 0xf0 ;
258
- static const uint8_t b64rmap_end = 0xfd ;
259
- static const uint8_t b64rmap_space = 0xfe ;
260
- static const uint8_t b64rmap_invalid = 0xff ;
257
+ static const uint8_t mongoc_b64rmap_special = 0xf0 ;
258
+ static const uint8_t mongoc_b64rmap_end = 0xfd ;
259
+ static const uint8_t mongoc_b64rmap_space = 0xfe ;
260
+ static const uint8_t mongoc_b64rmap_invalid = 0xff ;
261
261
262
262
/**
263
263
* Initializing the reverse map is not thread safe.
264
264
* Which is fine for NSD. For now...
265
265
**/
266
266
void
267
- b64_initialize_rmap (void )
267
+ mongoc_b64_initialize_rmap (void )
268
268
{
269
269
int i ;
270
270
unsigned char ch ;
271
271
272
272
/* Null: end of string, stop parsing */
273
- b64rmap [0 ] = b64rmap_end ;
273
+ mongoc_b64rmap [0 ] = mongoc_b64rmap_end ;
274
274
275
275
for (i = 1 ; i < 256 ; ++ i ) {
276
276
ch = (unsigned char )i ;
277
277
/* Whitespaces */
278
278
if (isspace (ch ))
279
- b64rmap [i ] = b64rmap_space ;
279
+ mongoc_b64rmap [i ] = mongoc_b64rmap_space ;
280
280
/* Padding: stop parsing */
281
281
else if (ch == Pad64 )
282
- b64rmap [i ] = b64rmap_end ;
282
+ mongoc_b64rmap [i ] = mongoc_b64rmap_end ;
283
283
/* Non-base64 char */
284
284
else
285
- b64rmap [i ] = b64rmap_invalid ;
285
+ mongoc_b64rmap [i ] = mongoc_b64rmap_invalid ;
286
286
}
287
287
288
288
/* Fill reverse mapping for base64 chars */
289
289
for (i = 0 ; Base64 [i ] != '\0' ; ++ i )
290
- b64rmap [(uint8_t )Base64 [i ]] = i ;
290
+ mongoc_b64rmap [(uint8_t )Base64 [i ]] = i ;
291
291
292
- b64rmap_initialized = 1 ;
292
+ mongoc_b64rmap_initialized = 1 ;
293
293
}
294
294
295
295
static int
296
- b64_pton_do (char const * src , uint8_t * target , size_t targsize )
296
+ mongoc_b64_pton_do (char const * src , uint8_t * target , size_t targsize )
297
297
{
298
298
int tarindex , state , ch ;
299
299
uint8_t ofs ;
@@ -304,14 +304,14 @@ b64_pton_do(char const *src, uint8_t *target, size_t targsize)
304
304
while (1 )
305
305
{
306
306
ch = * src ++ ;
307
- ofs = b64rmap [ch ];
307
+ ofs = mongoc_b64rmap [ch ];
308
308
309
- if (ofs >= b64rmap_special ) {
309
+ if (ofs >= mongoc_b64rmap_special ) {
310
310
/* Ignore whitespaces */
311
- if (ofs == b64rmap_space )
311
+ if (ofs == mongoc_b64rmap_space )
312
312
continue ;
313
313
/* End of base64 characters */
314
- if (ofs == b64rmap_end )
314
+ if (ofs == mongoc_b64rmap_end )
315
315
break ;
316
316
/* A non-base64 character. */
317
317
return (-1 );
@@ -369,7 +369,7 @@ b64_pton_do(char const *src, uint8_t *target, size_t targsize)
369
369
case 2 : /* Valid, means one byte of info */
370
370
/* Skip any number of spaces. */
371
371
for ((void )NULL ; ch != '\0' ; ch = * src ++ )
372
- if (b64rmap [ch ] != b64rmap_space )
372
+ if (mongoc_b64rmap [ch ] != mongoc_b64rmap_space )
373
373
break ;
374
374
/* Make sure there is another trailing = sign. */
375
375
if (ch != Pad64 )
@@ -384,7 +384,7 @@ b64_pton_do(char const *src, uint8_t *target, size_t targsize)
384
384
* whitespace after it?
385
385
*/
386
386
for ((void )NULL ; ch != '\0' ; ch = * src ++ )
387
- if (b64rmap [ch ] != b64rmap_space )
387
+ if (mongoc_b64rmap [ch ] != mongoc_b64rmap_space )
388
388
return (-1 );
389
389
390
390
/*
@@ -412,7 +412,7 @@ b64_pton_do(char const *src, uint8_t *target, size_t targsize)
412
412
413
413
414
414
static int
415
- b64_pton_len (char const * src )
415
+ mongoc_b64_pton_len (char const * src )
416
416
{
417
417
int tarindex , state , ch ;
418
418
uint8_t ofs ;
@@ -423,14 +423,14 @@ b64_pton_len(char const *src)
423
423
while (1 )
424
424
{
425
425
ch = * src ++ ;
426
- ofs = b64rmap [ch ];
426
+ ofs = mongoc_b64rmap [ch ];
427
427
428
- if (ofs >= b64rmap_special ) {
428
+ if (ofs >= mongoc_b64rmap_special ) {
429
429
/* Ignore whitespaces */
430
- if (ofs == b64rmap_space )
430
+ if (ofs == mongoc_b64rmap_space )
431
431
continue ;
432
432
/* End of base64 characters */
433
- if (ofs == b64rmap_end )
433
+ if (ofs == mongoc_b64rmap_end )
434
434
break ;
435
435
/* A non-base64 character. */
436
436
return (-1 );
@@ -472,7 +472,7 @@ b64_pton_len(char const *src)
472
472
case 2 : /* Valid, means one byte of info */
473
473
/* Skip any number of spaces. */
474
474
for ((void )NULL ; ch != '\0' ; ch = * src ++ )
475
- if (b64rmap [ch ] != b64rmap_space )
475
+ if (mongoc_b64rmap [ch ] != mongoc_b64rmap_space )
476
476
break ;
477
477
/* Make sure there is another trailing = sign. */
478
478
if (ch != Pad64 )
@@ -487,7 +487,7 @@ b64_pton_len(char const *src)
487
487
* whitespace after it?
488
488
*/
489
489
for ((void )NULL ; ch != '\0' ; ch = * src ++ )
490
- if (b64rmap [ch ] != b64rmap_space )
490
+ if (mongoc_b64rmap [ch ] != mongoc_b64rmap_space )
491
491
return (-1 );
492
492
493
493
default :
@@ -507,15 +507,15 @@ b64_pton_len(char const *src)
507
507
508
508
509
509
int
510
- b64_pton (char const * src , uint8_t * target , size_t targsize )
510
+ mongoc_b64_pton (char const * src , uint8_t * target , size_t targsize )
511
511
{
512
- if (!b64rmap_initialized )
513
- b64_initialize_rmap ();
512
+ if (!mongoc_b64rmap_initialized )
513
+ mongoc_b64_initialize_rmap ();
514
514
515
515
if (target )
516
- return b64_pton_do (src , target , targsize );
516
+ return mongoc_b64_pton_do (src , target , targsize );
517
517
else
518
- return b64_pton_len (src );
518
+ return mongoc_b64_pton_len (src );
519
519
}
520
520
521
521
#endif /* MONGOC_ENABLE_SSL */
0 commit comments