Changeset 3225:084d4f6251fe in roaraudio for libroar/auth.c


Ignore:
Timestamp:
01/24/10 08:11:17 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

function to convert auth type names and IDs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/auth.c

    r3221 r3225  
    136136} 
    137137 
     138// String functions: 
     139static struct { 
     140 int    type; 
     141 char * name; 
     142} _g_authts[] = { 
     143// grep ^'#define ROAR_AUTH_T_' auth.h | while read d t d; do n=$(cut -d_ -f4 <<<$t | tr A-Z a-z); printf ' {%-28s %-10s},\n' $t, \"$n\"; done 
     144 {ROAR_AUTH_T_NONE,            "none"    }, 
     145 {ROAR_AUTH_T_COOKIE,          "cookie"  }, 
     146 {ROAR_AUTH_T_TRUST,           "trust"   }, 
     147 {ROAR_AUTH_T_PASSWORD,        "password"}, 
     148 {ROAR_AUTH_T_SYSUSER,         "sysuser" }, 
     149 {ROAR_AUTH_T_OPENPGP_SIGN,    "openpgp" }, 
     150 {ROAR_AUTH_T_OPENPGP_ENCRYPT, "openpgp" }, 
     151 {ROAR_AUTH_T_OPENPGP_AUTH,    "openpgp" }, 
     152 {ROAR_AUTH_T_KERBEROS,        "kerberos"}, 
     153 {ROAR_AUTH_T_RHOST,           "rhost"   }, 
     154 {ROAR_AUTH_T_XAUTH,           "xauth"   }, 
     155 {ROAR_AUTH_T_IDENT,           "ident"   }, 
     156 {-1, NULL} 
     157}; 
     158 
     159int    roar_str2autht(char * str) { 
     160 int i; 
     161 
     162 for (i = 0; _g_authts[i].name != NULL; i++) 
     163  if ( !strcasecmp(_g_authts[i].name, str) ) 
     164   return _g_authts[i].type; 
     165 
     166 return -1; 
     167} 
     168 
     169char * roar_autht2str(int auth) { 
     170 int i; 
     171 
     172 for (i = 0; _g_authts[i].name != NULL; i++) 
     173  if ( _g_authts[i].type == auth ) 
     174   return _g_authts[i].name; 
     175 
     176 return "(UNKNOWN)"; 
     177} 
     178 
    138179//ll 
Note: See TracChangeset for help on using the changeset viewer.