Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 11th, 2012  |  syntax: None  |  size: 0.77 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. flock-ing a C   ifstream on Linux (GCC 4.6)
  2. { "_user" : "basile" ;
  3.    "_crypasswd" : "XYZABC123" ;
  4.    "_email" : "basile@starynkevitch.net" ;
  5.    "firstname" : "Basile" ;
  6.    "lastname" : "Starynkevitch" ;
  7.    "privileges" : "all" ;
  8.  }
  9.        
  10. extern char* iaca_passwd_path; // the path of the password file
  11. std::ifstream jsinpass(iaca_passwd_path);
  12. Json::Value jpassarr;
  13. Json::Reader reader;
  14. reader.parse(jsinpass,jpassarr,true);
  15. jsinpass.close();
  16. assert (jpassarr.isArray());
  17. for (int ix=0; ix<nbu; ix++) {
  18.   const Json::Value&jcuruser= jpassarr[ix];
  19.   assert(jcuruser.isObject());
  20.   if (jcuruser["_user"].compare(user) == 0) {
  21.     std::string crypasswd = jcuruser["_crypasswd"].asString();
  22.     if (crypasswd.compare(crypted_password(user,password)) == 0) {
  23.          // good user
  24.     }
  25.   }
  26. }