Subdomain Posts
C++ | 9 hours ago
C++ | 10 hours ago
C | 10 hours ago
C++ | 11 hours ago
C | 3 days ago
C | 5 days ago
C | 5 days ago
C | 5 days ago
SQL | 5 days ago
C | 6 days ago
Recent Posts
None | 4 sec ago
None | 22 sec ago
None | 38 sec ago
Ruby | 43 sec ago
None | 53 sec ago
None | 1 min ago
None | 1 min ago
C | 1 min ago
Java | 1 min ago
PHP | 1 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By mfp on the 23rd of Jan 2010 12:31:38 AM Download | Raw | Embed | Report
  1.  
  2. /* Open a database file and connect a hash database object. */
  3. bool tchdbopen(TCHDB *hdb, const char *path, int omode){
  4.   assert(hdb && path);
  5.   if(!HDBLOCKMETHOD(hdb, true)) return false;
  6.   if(hdb->fd >= 0){
  7.     tchdbsetecode(hdb, TCEINVALID, __FILE__, __LINE__, __func__);
  8.     HDBUNLOCKMETHOD(hdb);
  9.     return false;
  10.   }
  11.   char *rpath = tcrealpath(path);
  12.   if(!rpath){
  13.     int ecode = TCEOPEN;
  14.     switch(errno){
  15.     case EACCES: ecode = TCENOPERM; break;
  16.     case ENOENT: ecode = TCENOFILE; break;
  17.     case ENOTDIR: ecode = TCENOFILE; break;
  18.     }
  19.     tchdbsetecode(hdb, ecode, __FILE__, __LINE__, __func__);
  20.     HDBUNLOCKMETHOD(hdb);
  21.     return false;
  22.   }
  23.   if(!tcpathlock(rpath)){
  24.     tchdbsetecode(hdb, TCETHREAD, __FILE__, __LINE__, __func__);
  25.     TCFREE(rpath);
  26.     HDBUNLOCKMETHOD(hdb);
  27.     return false;
  28.   }
  29.   bool rv = tchdbopenimpl(hdb, path, omode);
  30.   if(rv){
  31.     hdb->rpath = rpath;
  32.   } else {
  33.     tcpathunlock(rpath);
  34.     TCFREE(rpath);
  35.   }
  36.   HDBUNLOCKMETHOD(hdb);
  37.   return rv;
  38. }
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: