numpack.c revision a6050e85dfaa9af0a7b4e059c198df6dc0133388
/* Copyright (c) 2013-2014 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "buffer.h"
#include "numpack.h"
{
/* number continues as long as the highest bit is set */
while (num >= 0x80) {
num >>= 7;
}
}
{
const uint8_t *c = *p;
unsigned int bits = 0;
while (bits < 64) {
if (c == end)
return -1;
if (*c < 0x80)
break;
bits += 7;
c++;
}
bits += bits_required8(*c);
return -1;
*p = c + 1;
return 0;
}