FreeBSD/contrib/subversion/subversion/libsvn_fs_fs/temp_serializer.c
/* Utility to encode a signed NUMBER into a variable-length sequence of
 * 8-bit chars in KEY_BUFFER and return the last writen position.
 *
 * Numbers will be stored in 7 bits / byte and using byte values above
 * 32 (' ') to make them combinable with other string by simply separating
 * individual parts with spaces.
 */
Utility to encode a signed NUMBER into a variable-length sequence of
8-bit chars in KEY_BUFFER and return the last writen position.

Numbers will be stored in 7 bits / byte and using byte values above
32 (' ') to make them combinable with other string by simply separating
individual parts with spaces.
Utility to encode a signed NUMBER into a variable - length sequence of 8 - bit chars in KEY_BUFFER and return the last writen position . Numbers will be stored in 7 bits / byte and using byte values above 32 ( ' ' ) to make them combinable with other string by simply separating individual parts with spaces .
static char*
encode_number(apr_int64_t number, char *key_buffer)
{
  if (number < 0)
  {
    number = -number;
    *key_buffer = (char)((number & 63) + ' ' + 65);
  }
  else
    *key_buffer = (char)((number & 63) + ' ' + 1);
  number /= 64;
  while (number)
  {
    *++key_buffer = (char)((number & 127) + ' ' + 1);
    number /= 128;
  }
  return key_buffer;
}
static char * encode_number ( apr_int64_t number , char * key_buffer ) { if ( number < 0 ) { number = - number ; * key_buffer = ( char ) ( ( number & 63 ) + ' ' + 65 ) ; } else * key_buffer = ( char ) ( ( number & 63 ) + ' ' + 1 ) ; number /= 64 ; while ( number ) { * ++ key_buffer = ( char ) ( ( number & 127 ) + ' ' + 1 ) ; number /= 128 ; } return key_buffer ; }
Utility to encode a signed NUMBER into a variable-length sequence of
 8-bit chars in KEY_BUFFER and return the last writen position.
Utility to encode a signed NUMBER into a variable - length sequence of 8 - bit chars in KEY_BUFFER and return the last writen position .
/* encode the sign in the first byte */ /* write 7 bits / byte until no significant bits are left */ /* return the last written position */