Defines | Functions | Variables

basex.h File Reference

SIP-router core :: convert/decode to/from ascii using various bases. More...

#include "compiler_opt.h"
#include "endianness.h"
Include dependency graph for basex.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

Functions

Variables


Detailed Description

Module: SIP-router core

Functions:

All the above functions return the size used (in dst) on success and 0 or a negative number (which is -1*size_needed) on error.

There are close to no checks for validity, an unexpected char will lead to a corrupted result, but the functions won't return error.

Notes: on a core2 duo the versions with lookup tables are way faster (see http://www.experts-exchange.com/Programming/Languages/CPP/Q_21988706.html for some interesting tests and ideeas).

Test results for 40 bytes (typical ser nounce) in average cpu cycles:

 *                    lookup   lookup_large lookup8k no-lookup
 *  base16_enc           211/231  218/199      -       1331
 *  base16_dec           252/251  236          -       1226
 *  base64_enc           209      186         156      1005
 *  base64_dec           208      207         207      1242
 *  q_base64_enc         -                              288
 *  q_base64_dec         -                              281
 *  (see test/basex.txt for more results)

Defines:

History: -------- 2008-06-11 created by andrei

Definition in file basex.h.


Define Documentation

#define UNHEX (   h  )     _bx_unhexdig256[(h)]
Returns:
0xff for invalid digit (but with some compile option it won't check)

Definition at line 150 of file basex.h.


Function Documentation

static int base16_enc ( unsigned char *  src,
int  slen,
unsigned char *  dst,
int  dlen 
) [inline, static]
Returns:
: size used from the output buffer (dst) on success, -size_needed on error
Note:
WARNING: the output string is not 0-term

Definition at line 460 of file basex.h.

References HEX_HI, and HEX_LOW.

static int base64_dec ( unsigned char *  src,
int  slen,
unsigned char *  dst,
int  dlen 
) [inline, static]
Returns:
size used from the output buffer (dst) on success (max: slen/4*3) -size_needed on error or 0 on bad base64 encoded string
Note:
WARNING: the output string is not 0-term

Definition at line 661 of file basex.h.

static unsigned base64_dec_char ( unsigned char  v  )  [inline, static]
Returns:
value on success (0-63) and 0xff on error (invalid)

Definition at line 521 of file basex.h.

static int base64_enc ( unsigned char *  src,
int  slen,
unsigned char *  dst,
int  dlen 
) [inline, static]
Returns:
: size used from the output buffer (dst) on success ((slen+2)/3*4) -size_needed on error
Note:
WARNING: the output string is not 0-term

Definition at line 563 of file basex.h.

static unsigned char base64_enc_char ( unsigned char  v  )  [inline, static]
Returns:
char ascii encoding on success and 0xff on error (value out of range)

Definition at line 501 of file basex.h.

static int q_base64_dec ( unsigned char *  src,
int  slen,
unsigned char *  dst,
int  dlen 
) [inline, static]
Returns:
size used from the output buffer (dst) on success (max: slen/4*3) -size_needed on error or 0 on bad base64 encoded string
Note:
WARNING: the output string is not 0-term

Definition at line 777 of file basex.h.

static int q_base64_enc ( unsigned char *  src,
int  slen,
unsigned char *  dst,
int  dlen 
) [inline, static]
Returns:
size used from the output buffer (dst) on success ((slen+2)/3*4) -size_needed on error
Note:
WARNING: the alphabet includes ":;<>?@[]\`", so it might not be suited in all cases (e.g. encoding something in a sip uri).

Definition at line 730 of file basex.h.