X-Git-Url: http://tinc-vpn.org/git/browse?a=blobdiff_plain;f=lib%2Futils.c;h=1d46630b0782be4c1e35ff805c7fc38539535977;hb=075e6828a7533e7daa790225f17aa6bb39703278;hp=b00a73bc7c5e7adc2d3f4305f77f1bb654844cb5;hpb=08aabbf9317806bc50a9a6693ca866c8936ce26b;p=tinc diff --git a/lib/utils.c b/lib/utils.c index b00a73bc..1d46630b 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -29,7 +29,7 @@ volatile char (*cp_file[]) = {"?", "?", "?", "?", "?", "?", "?", "?", "?", "?", volatile int cp_index = 0; #endif -char *hexadecimals = "0123456789ABCDEF"; +const char hexadecimals[] = "0123456789ABCDEF"; int charhex2bin(char c) { if(isdigit(c)) @@ -81,7 +81,7 @@ void cp_trace() { #include #endif -char *winerror(int err) { +const char *winerror(int err) { static char buf[1024], *newline; if (!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, @@ -96,3 +96,10 @@ 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; +}