imap/src/osdep/nt/env_nt.c
/* Lock file name
 * Accepts: return buffer for file name
 *	    file name
 *	    locking to be placed on file if non-NIL
 * Returns: file descriptor of lock or -1 if error
 */
Lock file name
Accepts: return buffer for file name
file name
locking to be placed on file if non-NIL
Returns: file descriptor of lock or -1 if error
Lock file name Accepts : return buffer for file name file name locking to be placed on file if non - NIL Returns : file descriptor of lock or - 1 if error
int lockname (char *lock,char *fname,int op)
{
  int ld;
  char c,*s;
  if (!((s = lockdir (lock,getenv ("windir"),"TEMP")) ||
	(s = lockdir (lock,getenv ("TEMP"),NIL)) ||
	(s = lockdir (lock,getenv ("TMP"),NIL)) ||
	(s = lockdir (lock,getenv ("TMPDIR"),NIL)) ||
	(s = lockdir (lock,defaultDrive (),"WINNT\\TEMP")) ||
	(s = lockdir (lock,defaultDrive (),"WINDOWS\\TEMP")) ||
	(s = lockdir (lock,defaultDrive (),"TEMP")))) {
    mm_log ("Unable to find temporary directory",ERROR);
    return -1;
  }
  while (c = *fname++) switch (c) {
  case '/': case '\\': case ':':
    *s++ = '!';			
    break;
  default:
    *s++ = c;
    break;
  }
  *s++ = c;			
  if (((ld = open (lock,O_BINARY|O_RDWR|O_CREAT,S_IREAD|S_IWRITE)) >= 0) && op)
    flock (ld,op);		
  return ld;			
}
int lockname ( char * lock , char * fname , int op ) { int ld ; char c , * s ; if ( ! ( ( s = lockdir ( lock , getenv ( " " ) , " " ) ) || ( s = lockdir ( lock , getenv ( " " ) , NIL ) ) || ( s = lockdir ( lock , getenv ( " " ) , NIL ) ) || ( s = lockdir ( lock , getenv ( " " ) , NIL ) ) || ( s = lockdir ( lock , defaultDrive ( ) , " \\ " ) ) || ( s = lockdir ( lock , defaultDrive ( ) , " \\ " ) ) || ( s = lockdir ( lock , defaultDrive ( ) , " " ) ) ) ) { mm_log ( " " , ERROR ) ; return -1 ; } while ( c = * fname ++ ) switch ( c ) { case ' ' : case ' \\ ' : case ' ' : * s ++ = ' ' ; break ; default : * s ++ = c ; break ; } * s ++ = c ; if ( ( ( ld = open ( lock , O_BINARY | O_RDWR | O_CREAT , S_IREAD | S_IWRITE ) ) >= 0 ) && op ) flock ( ld , op ) ; return ld ; }
Lock file name
 Accepts: return buffer for file name
          file name
          locking to be placed on file if non-NIL
 Returns: file descriptor of lock or -1 if error
Lock file name Accepts : return buffer for file name file name locking to be placed on file if non - NIL Returns : file descriptor of lock or - 1 if error
/* Win2K and Win98 have TEMP under windir */ /* NT4, NT3.x and Win95 use one of these */ /* try one of these */ /* C:\TEMP is last resort */ /* generate file name */ /* convert bad chars to ! */ /* tie off name */ /* get the lock */ /* apply locking function */ /* return locking file descriptor */