Changeset 4465:474d7731edd6 in roaraudio


Ignore:
Timestamp:
10/10/10 16:08:34 (8 years ago)
Author:
phi
Branch:
default
Message:

implemented simple function for asking for passwords

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/passwordapi.c

    r4462 r4465  
    3636#include "libroar.h" 
    3737 
     38ssize_t roar_passwd_simple_ask_pw (char ** pw, char * prompt, const char * cachetoken) { 
     39#ifdef ROAR_SUPPORT_PASSWORD_API 
     40 struct roar_pinentry pe; 
     41 
     42 if ( pw == NULL ) 
     43  return -1; 
     44 
     45 if ( prompt == NULL ) { 
     46  ROAR_WARN("roar_passwd_simple_ask_pw(pw=%p, prompt=NULL, cachetoken='%s'): No prompt given. This may be a bug in application."); 
     47  prompt = "Please enter Password"; 
     48 } 
     49 
     50 *pw = NULL; 
     51 
     52 // TODO: test for cache here. 
     53 
     54 if ( *pw == NULL ) { 
     55  if ( roar_pinentry_simple_open(&pe) != -1 ) { 
     56   if ( roar_pinentry_getpin(&pe, pw, NULL, prompt) == -1 ) { 
     57    *pw = NULL; 
     58   } 
     59   roar_pinentry_close(&pe); 
     60  } 
     61 } 
     62 
     63 if ( *pw == NULL ) { 
     64  if ( roar_sshaskpass_getpass(pw, prompt) == -1 ) { 
     65   *pw = NULL; 
     66  } 
     67 } 
     68 
     69 if ( *pw == NULL ) 
     70  return -1; 
     71 
     72 // TODO: save to cache here. 
     73 
     74 return strlen(*pw); 
     75#else 
     76 return -1; 
     77#endif 
     78} 
     79 
    3880//ll 
Note: See TracChangeset for help on using the changeset viewer.