- if (addr.sin_family) {
- if (f < 0)
- f = socket(AF_INET, SOCK_DGRAM, 0);
- if (f >= 0)
- sendto(f, msg, strlen(msg)+1, 0, &addr, sizeof (addr));
- }
-}
-
-sendmail(n, name, fromaddr)
- int n;
- char *name, *fromaddr;
-{
- char file[256];
- int mask, fd;
- struct passwd *pw;
-#ifdef notdef
- struct stat statb;
-#endif
- char buf[128];
-
- if (*name=='!')
- name++;
- if (any('!', name))
- return (sendrmt(n, name));
- if ((pw = getpwnam(name)) == NULL) {
- printf("mail: can't send to %s\n", name);
- return(0);
- }
- cat(file, maildir, name);
-#ifdef notdef
- if (stat(file, &statb) >= 0 && (statb.st_mode & S_IFMT) == S_IFDIR) {
- strcat(file, "/");
- strcat(file, name);
- }
-#endif
- if (!safefile(file))
- return(0);
- fd = open(file, O_WRONLY | O_CREAT, MAILMODE);
- if (fd >= 0) {
- flock(fd, LOCK_EX);
- malf = fdopen(fd, "a");
- }
- if (fd < 0 || malf == NULL) {
- close(fd);
- printf("mail: %s: cannot append\n", file);
- return(0);
- }
- fchown(fd, pw->pw_uid, pw->pw_gid);
- (void)sprintf(buf, "%s@%ld\n", name, ftell(malf));
- copylet(n, malf, ORDINARY);
- fclose(malf);
- notifybiff(buf);
- return(1);
-}
-
-delex(i)
-{
- if (i != SIGINT) {
- setsig(i, SIG_DFL);
- sigsetmask(sigblock(0L) &~ sigmask(i));
+ if (f < 0 && (f = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
+ error(NOTFATAL, "socket: %s.", strerror(errno));
+ return;