| 94 | } |
| 95 | |
| 96 | void |
| 97 | getmailstatus(void) |
| 98 | { |
| 99 | if (mailbox) { |
| 100 | ; /* no need to repeat the setup */ |
| 101 | } else if ((mailbox = nh_getenv("MAIL")) != 0) { |
| 102 | mailbox = dupstr(mailbox); |
| 103 | #ifdef MAILPATH |
| 104 | } else { |
| 105 | #ifdef AMS |
| 106 | struct passwd ppasswd; |
| 107 | |
| 108 | (void) memcpy(&ppasswd, getpwuid(getuid()), sizeof (struct passwd)); |
| 109 | if (ppasswd.pw_dir) { |
| 110 | /* note: 'sizeof "LITERAL"' includes +1 for terminating '\0' */ |
| 111 | mailbox = (char *) alloc((unsigned) (strlen(ppasswd.pw_dir) |
| 112 | + sizeof AMS_MAILBOX)); |
| 113 | Strcpy(mailbox, ppasswd.pw_dir); |
| 114 | Strcat(mailbox, AMS_MAILBOX); |
| 115 | } |
| 116 | #else |
| 117 | const char *pw_name = getpwuid(getuid())->pw_name; |
| 118 | |
| 119 | /* note: 'sizeof "LITERAL"' includes +1 for terminating '\0' */ |
| 120 | mailbox = (char *) alloc((unsigned) (strlen(pw_name) |
| 121 | + sizeof MAILPATH)); |
| 122 | Strcpy(mailbox, MAILPATH); |
| 123 | Strcat(mailbox, pw_name); |
| 124 | #endif /* AMS */ |
| 125 | #endif /* MAILPATH */ |
| 126 | } |
| 127 | |
| 128 | debugpline3("mailbox=%c%s%c", |
| 129 | mailbox ? '\"' : '<', |
| 130 | mailbox ? mailbox : "null", |
| 131 | mailbox ? '\"' : '>'); |
| 132 | |
| 133 | if (mailbox && stat(mailbox, &omstat)) { |
| 134 | #ifdef PERMANENT_MAILBOX |
| 135 | pline("Cannot get status of MAIL=\"%s\".", mailbox); |
| 136 | free_maildata(); /* set 'mailbox' to Null */ |
| 137 | #else |
| 138 | omstat.st_mtime = 0; |
| 139 | #endif |
| 140 | } |
| 141 | } |
| 142 | #endif /* UNIX */ |
| 143 | |
| 144 | /* |
no test coverage detected