Mercurial > dovecot > core-2.2
view src/lib/hex-dec.c @ 22656:1789bf2a1e01
director: Make sure HOST-RESET-USERS isn't used with max_moving_users=0
The reset command would just hang in that case. doveadm would never have
sent this, so this is just an extra sanity check.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sun, 05 Nov 2017 23:51:56 +0200 |
parents | 2e2563132d5f |
children | cb108f786fb4 |
line wrap: on
line source
/* Copyright (c) 2005-2017 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "hex-dec.h" void dec2hex(unsigned char *hexstr, uintmax_t dec, unsigned int hexstr_size) { unsigned int i; for (i = 0; i < hexstr_size; i++) { unsigned int value = dec & 0x0f; if (value < 10) hexstr[hexstr_size-i-1] = value + '0'; else hexstr[hexstr_size-i-1] = value - 10 + 'A'; dec >>= 4; } } uintmax_t hex2dec(const unsigned char *data, unsigned int len) { unsigned int i; uintmax_t value = 0; for (i = 0; i < len; i++) { value = value*0x10; if (data[i] >= '0' && data[i] <= '9') value += data[i]-'0'; else if (data[i] >= 'A' && data[i] <= 'F') value += data[i]-'A' + 10; else if (data[i] >= 'a' && data[i] <= 'f') value += data[i]-'a' + 10; else return 0; } return value; }