+ {
+ struct stat st;
+ int myuid = getuid();
+ static char path[5 /* strlen ("/tmp/") */ + 1 + _POSIX_PATH_MAX];
+
+ strcpy (path, "/tmp/");
+ strncat (path, user_login_name (NULL), _POSIX_PATH_MAX);
+ if (lstat(path, &st) < 0 && errno == ENOENT)
+ {
+ mkdir(path, 0700); /* ignore retval -- checked next anyway. */
+ }
+ if (lstat(path, &st) == 0 && st.st_uid == (uid_t) myuid &&
+ S_ISDIR(st.st_mode))
+ {
+ tmpdir = path;
+ }
+ else
+ {
+ path[5 + _POSIX_PATH_MAX] = '\0';
+ strncpy(path, getenv("HOME"), 5 + _POSIX_PATH_MAX);
+ strncat(path, "/tmp/", 5 + _POSIX_PATH_MAX);
+ if (stat(path, &st) < 0 && errno == ENOENT)
+ {
+ int fd;
+ char warnpath[6+_POSIX_PATH_MAX];
+ mkdir(path, 0700); /* ignore retvals */
+ warnpath[_POSIX_PATH_MAX] = '\0';
+ strncpy(warnpath, path, 5 + _POSIX_PATH_MAX);
+ strncat(warnpath, ".created_by_xemacs", 5 + _POSIX_PATH_MAX);
+ if ((fd = open(warnpath, O_WRONLY|O_CREAT, 0644)) > 0)
+ {
+ write(fd, "XEmacs created this directory because /tmp/<yourname> was unavailable -- \nPlease check !\n", 89);
+ close(fd);
+ }
+ }
+ if (stat(path, &st) == 0 && S_ISDIR(st.st_mode))
+ {
+ tmpdir = path;
+ }
+ else
+ {