X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fncaps-net.c;h=be8ce9c66601993a1df1f63a3677b08f93f7b7c3;hb=0d4cba12770c5b09a3380f456a6a2f6787042ee7;hp=9154cb7d320dcd25f9c349f583730c3f9a252a6e;hpb=9c78378bebc1a9f3d400f422df8ede9efea57dea;p=util-vserver.git diff --git a/lib/ncaps-net.c b/lib/ncaps-net.c index 9154cb7..be8ce9c 100644 --- a/lib/ncaps-net.c +++ b/lib/ncaps-net.c @@ -25,6 +25,7 @@ #include #include +#include #include #define DECL(STR, VAL) { STR, sizeof(STR)-1, VAL } @@ -34,10 +35,23 @@ static struct Mapping_uint64 const VALUES[] = { DECL("", 0) }; +inline static char const * +removePrefix(char const *str, size_t *len) +{ + if ((len==0 || *len==0 || *len>4) && + strncasecmp("nxc_", str, 4)==0) { + if (len && *len>4) *len -= 4; + return str+4; + } + else + return str; +} + uint_least64_t vc_text2ncap(char const *str, size_t len) { - ssize_t idx = utilvserver_value2text_uint64(str, len, + char const * tmp = removePrefix(str, &len); + ssize_t idx = utilvserver_value2text_uint64(tmp, len, VALUES, DIM_OF(VALUES)); if (idx==-1) return 0; else return VALUES[idx].val;