X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Futils.c;h=4795ed0e89caad72ab544ee8339cb2611bbdba04;hp=56bcb0b1b35d8687be63c346ce2690e69063aff4;hb=ab7c61b06f6c6e991225f2fcc32d02b8e1084aee;hpb=a5fb0d8c6c384b9ea1074fb469c0a3dd5b874e98 diff --git a/lib/utils.c b/lib/utils.c index 56bcb0b1..4795ed0e 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -1,7 +1,7 @@ /* utils.c -- gathering of some stupid small functions - Copyright (C) 1999-2005 Ivo Timmermans - 2000-2006 Guus Sliepen + Copyright (C) 1999-2005 Ivo Timmermans + 2000-2009 Guus Sliepen This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "system.h" @@ -100,3 +100,10 @@ const char *winerror(int err) { } #endif +unsigned int bitfield_to_int(void *bitfield, size_t size) { + unsigned int value = 0; + if(size > sizeof value) + size = sizeof value; + memcpy(&value, bitfield, size); + return value; +}