| 78 | } |
| 79 | |
| 80 | static int add_mailname_host(struct strbuf *buf) |
| 81 | { |
| 82 | FILE *mailname; |
| 83 | struct strbuf mailnamebuf = STRBUF_INIT; |
| 84 | |
| 85 | mailname = fopen_or_warn("/etc/mailname", "r"); |
| 86 | if (!mailname) |
| 87 | return -1; |
| 88 | |
| 89 | if (strbuf_getline(&mailnamebuf, mailname) == EOF) { |
| 90 | if (ferror(mailname)) |
| 91 | warning_errno("cannot read /etc/mailname"); |
| 92 | strbuf_release(&mailnamebuf); |
| 93 | fclose(mailname); |
| 94 | return -1; |
| 95 | } |
| 96 | /* success! */ |
| 97 | strbuf_addbuf(buf, &mailnamebuf); |
| 98 | strbuf_release(&mailnamebuf); |
| 99 | fclose(mailname); |
| 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | static int canonical_name(const char *host, struct strbuf *out) |
| 104 | { |
no test coverage detected