LCOV - code coverage report
Current view: top level - basic - cap-from-name.h (source / functions) Hit Total Coverage
Test: systemd test coverage Lines: 23 23 100.0 %
Date: 2015-07-29 18:47:03 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /* ANSI-C code produced by gperf version 3.0.4 */
       2             : /* Command-line: gperf -L ANSI-C -t --ignore-case -N lookup_capability -H hash_capability_name -p -C  */
       3             : /* Computed positions: -k'5,8-9' */
       4             : 
       5             : #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
       6             :       && ('%' == 37) && ('&' == 38) && ('\'' == 39) && ('(' == 40) \
       7             :       && (')' == 41) && ('*' == 42) && ('+' == 43) && (',' == 44) \
       8             :       && ('-' == 45) && ('.' == 46) && ('/' == 47) && ('0' == 48) \
       9             :       && ('1' == 49) && ('2' == 50) && ('3' == 51) && ('4' == 52) \
      10             :       && ('5' == 53) && ('6' == 54) && ('7' == 55) && ('8' == 56) \
      11             :       && ('9' == 57) && (':' == 58) && (';' == 59) && ('<' == 60) \
      12             :       && ('=' == 61) && ('>' == 62) && ('?' == 63) && ('A' == 65) \
      13             :       && ('B' == 66) && ('C' == 67) && ('D' == 68) && ('E' == 69) \
      14             :       && ('F' == 70) && ('G' == 71) && ('H' == 72) && ('I' == 73) \
      15             :       && ('J' == 74) && ('K' == 75) && ('L' == 76) && ('M' == 77) \
      16             :       && ('N' == 78) && ('O' == 79) && ('P' == 80) && ('Q' == 81) \
      17             :       && ('R' == 82) && ('S' == 83) && ('T' == 84) && ('U' == 85) \
      18             :       && ('V' == 86) && ('W' == 87) && ('X' == 88) && ('Y' == 89) \
      19             :       && ('Z' == 90) && ('[' == 91) && ('\\' == 92) && (']' == 93) \
      20             :       && ('^' == 94) && ('_' == 95) && ('a' == 97) && ('b' == 98) \
      21             :       && ('c' == 99) && ('d' == 100) && ('e' == 101) && ('f' == 102) \
      22             :       && ('g' == 103) && ('h' == 104) && ('i' == 105) && ('j' == 106) \
      23             :       && ('k' == 107) && ('l' == 108) && ('m' == 109) && ('n' == 110) \
      24             :       && ('o' == 111) && ('p' == 112) && ('q' == 113) && ('r' == 114) \
      25             :       && ('s' == 115) && ('t' == 116) && ('u' == 117) && ('v' == 118) \
      26             :       && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
      27             :       && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
      28             : /* The character set is not based on ISO-646.  */
      29             : #error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
      30             : #endif
      31             : 
      32             : struct capability_name { const char* name; int id; };
      33             : 
      34             : #define TOTAL_KEYWORDS 38
      35             : #define MIN_WORD_LENGTH 8
      36             : #define MAX_WORD_LENGTH 20
      37             : #define MIN_HASH_VALUE 8
      38             : #define MAX_HASH_VALUE 61
      39             : /* maximum key range = 54, duplicates = 0 */
      40             : 
      41             : #ifndef GPERF_DOWNCASE
      42             : #define GPERF_DOWNCASE 1
      43             : static unsigned char gperf_downcase[256] =
      44             :   {
      45             :       0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,  13,  14,
      46             :      15,  16,  17,  18,  19,  20,  21,  22,  23,  24,  25,  26,  27,  28,  29,
      47             :      30,  31,  32,  33,  34,  35,  36,  37,  38,  39,  40,  41,  42,  43,  44,
      48             :      45,  46,  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,  59,
      49             :      60,  61,  62,  63,  64,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106,
      50             :     107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
      51             :     122,  91,  92,  93,  94,  95,  96,  97,  98,  99, 100, 101, 102, 103, 104,
      52             :     105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119,
      53             :     120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134,
      54             :     135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149,
      55             :     150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164,
      56             :     165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179,
      57             :     180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194,
      58             :     195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
      59             :     210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224,
      60             :     225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
      61             :     240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254,
      62             :     255
      63             :   };
      64             : #endif
      65             : 
      66             : #ifndef GPERF_CASE_STRCMP
      67             : #define GPERF_CASE_STRCMP 1
      68             : static int
      69         587 : gperf_case_strcmp (register const char *s1, register const char *s2)
      70             : {
      71             :   for (;;)
      72             :     {
      73         587 :       unsigned char c1 = gperf_downcase[(unsigned char)*s1++];
      74         587 :       unsigned char c2 = gperf_downcase[(unsigned char)*s2++];
      75         587 :       if (c1 != 0 && c1 == c2)
      76         546 :         continue;
      77          41 :       return (int)c1 - (int)c2;
      78         546 :     }
      79             : }
      80             : #endif
      81             : 
      82             : #ifdef __GNUC__
      83             : __inline
      84             : #else
      85             : #ifdef __cplusplus
      86             : inline
      87             : #endif
      88             : #endif
      89             : static unsigned int
      90          41 : hash_capability_name (register const char *str, register unsigned int len)
      91             : {
      92             :   static const unsigned char asso_values[] =
      93             :     {
      94             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
      95             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
      96             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
      97             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
      98             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
      99             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     100             :       62, 62, 62, 62, 62,  5, 20, 20,  0,  0,
     101             :        0, 20, 62,  0, 62,  0,  0, 15, 10, 25,
     102             :       30, 62,  0,  0,  5,  0, 62,  0, 35, 62,
     103             :       62, 62, 62, 62, 62,  0, 62,  5, 20, 20,
     104             :        0,  0,  0, 20, 62,  0, 62,  0,  0, 15,
     105             :       10, 25, 30, 62,  0,  0,  5,  0, 62,  0,
     106             :       35, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     107             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     108             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     109             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     110             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     111             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     112             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     113             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     114             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     115             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     116             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     117             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     118             :       62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
     119             :       62, 62, 62, 62, 62, 62
     120             :     };
     121          41 :   register int hval = len;
     122             : 
     123          41 :   switch (hval)
     124             :     {
     125             :       default:
     126          40 :         hval += asso_values[(unsigned char)str[8]];
     127             :       /*FALLTHROUGH*/
     128             :       case 8:
     129          41 :         hval += asso_values[(unsigned char)str[7]];
     130             :       /*FALLTHROUGH*/
     131             :       case 7:
     132             :       case 6:
     133             :       case 5:
     134          41 :         hval += asso_values[(unsigned char)str[4]];
     135          41 :         break;
     136             :     }
     137          41 :   return hval;
     138             : }
     139             : 
     140             : #ifdef __GNUC__
     141             : __inline
     142             : #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
     143             : __attribute__ ((__gnu_inline__))
     144             : #endif
     145             : #endif
     146             : const struct capability_name *
     147          43 : lookup_capability (register const char *str, register unsigned int len)
     148             : {
     149             :   static const struct capability_name wordlist[] =
     150             :     {
     151             :       {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
     152             :       {(char*)0}, {(char*)0}, {(char*)0}, {(char*)0},
     153             :       {"CAP_KILL", CAP_KILL},
     154             :       {"CAP_LEASE", CAP_LEASE},
     155             :       {"CAP_SETUID", CAP_SETUID},
     156             :       {(char*)0},
     157             :       {"CAP_IPC_LOCK", CAP_IPC_LOCK},
     158             :       {"CAP_SYS_RAWIO", CAP_SYS_RAWIO},
     159             :       {"CAP_WAKE_ALARM", CAP_WAKE_ALARM},
     160             :       {"CAP_FSETID", CAP_FSETID},
     161             :       {"CAP_SYS_RESOURCE", CAP_SYS_RESOURCE},
     162             :       {"CAP_SYS_TIME", CAP_SYS_TIME},
     163             :       {"CAP_SYS_ADMIN", CAP_SYS_ADMIN},
     164             :       {"CAP_DAC_READ_SEARCH", CAP_DAC_READ_SEARCH},
     165             :       {"CAP_FOWNER", CAP_FOWNER},
     166             :       {"CAP_NET_RAW", CAP_NET_RAW},
     167             :       {"CAP_SYS_NICE", CAP_SYS_NICE},
     168             :       {"CAP_SYS_TTY_CONFIG", CAP_SYS_TTY_CONFIG},
     169             :       {"CAP_AUDIT_READ", CAP_AUDIT_READ},
     170             :       {"CAP_AUDIT_WRITE", CAP_AUDIT_WRITE},
     171             :       {(char*)0},
     172             :       {"CAP_AUDIT_CONTROL", CAP_AUDIT_CONTROL},
     173             :       {"CAP_NET_ADMIN", CAP_NET_ADMIN},
     174             :       {"CAP_SYS_MODULE", CAP_SYS_MODULE},
     175             :       {"CAP_SETGID", CAP_SETGID},
     176             :       {"CAP_SETFCAP", CAP_SETFCAP},
     177             :       {"CAP_SYS_BOOT", CAP_SYS_BOOT},
     178             :       {"CAP_MAC_ADMIN", CAP_MAC_ADMIN},
     179             :       {"CAP_SYS_CHROOT", CAP_SYS_CHROOT},
     180             :       {"CAP_SYSLOG", CAP_SYSLOG},
     181             :       {(char*)0}, {(char*)0},
     182             :       {"CAP_IPC_OWNER", CAP_IPC_OWNER},
     183             :       {"CAP_CHOWN", CAP_CHOWN},
     184             :       {(char*)0},
     185             :       {"CAP_DAC_OVERRIDE", CAP_DAC_OVERRIDE},
     186             :       {(char*)0},
     187             :       {"CAP_SYS_PACCT", CAP_SYS_PACCT},
     188             :       {"CAP_SYS_PTRACE", CAP_SYS_PTRACE},
     189             :       {(char*)0}, {(char*)0},
     190             :       {"CAP_NET_BROADCAST", CAP_NET_BROADCAST},
     191             :       {(char*)0},
     192             :       {"CAP_MKNOD", CAP_MKNOD},
     193             :       {"CAP_NET_BIND_SERVICE", CAP_NET_BIND_SERVICE},
     194             :       {(char*)0}, {(char*)0}, {(char*)0},
     195             :       {"CAP_LINUX_IMMUTABLE", CAP_LINUX_IMMUTABLE},
     196             :       {(char*)0},
     197             :       {"CAP_MAC_OVERRIDE", CAP_MAC_OVERRIDE},
     198             :       {"CAP_BLOCK_SUSPEND", CAP_BLOCK_SUSPEND},
     199             :       {(char*)0}, {(char*)0}, {(char*)0},
     200             :       {"CAP_SETPCAP", CAP_SETPCAP}
     201             :     };
     202             : 
     203          43 :   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
     204             :     {
     205          41 :       register int key = hash_capability_name (str, len);
     206             : 
     207          41 :       if (key <= MAX_HASH_VALUE && key >= 0)
     208             :         {
     209          41 :           register const char *s = wordlist[key].name;
     210             : 
     211          41 :           if (s && (((unsigned char)*str ^ (unsigned char)*s) & ~32) == 0 && !gperf_case_strcmp (str, s))
     212          41 :             return &wordlist[key];
     213             :         }
     214             :     }
     215           2 :   return 0;
     216             : }

Generated by: LCOV version 1.11