ports/mail/nmh/patches/patch-uip_rcvtty_c

71 lines
1.6 KiB
Text

Upstream no longer supports utmp...
http://git.savannah.gnu.org/cgit/nmh.git/patch/?id=7ba29497ff3f164e2a507eda35e81f1cb0658c74
Backout recent breakage...
http://git.savannah.gnu.org/cgit/nmh.git/patch/?id=6443ed24f6c3b41186636a0b0fea93ebe9452047
Index: uip/rcvtty.c
--- uip/rcvtty.c.orig
+++ uip/rcvtty.c
@@ -36,6 +36,8 @@
#ifdef HAVE_GETUTXENT
#include <utmpx.h>
+#else
+#include <utmp.h>
#endif /* HAVE_GETUTXENT */
#define SCANFMT \
@@ -77,9 +79,7 @@ static char *format = NULL;
static void alrmser (int);
static int message_fd (char **);
static int header_fd (void);
-#if HAVE_GETUTXENT
static void alert (char *, int);
-#endif /* HAVE_GETUTXENT */
int
@@ -88,7 +88,12 @@ main (int argc, char **argv)
int md, vecp = 0;
char *cp, *user, buf[BUFSIZ];
char **argp, **arguments, *vec[MAXARGS];
+#if HAVE_GETUTXENT
struct utmpx *utp;
+#else
+ struct utmp ut;
+ register FILE *uf;
+#endif
if (nmh_init(argv[0], true, false)) { return 1; }
@@ -169,7 +174,14 @@ main (int argc, char **argv)
}
endutxent();
#else
- NMH_UNUSED (utp);
+ if ((uf = fopen(_PATH_UTMP, "r")) == NULL)
+ exit(1);
+ while (fread((char *) &ut, sizeof(ut), 1, uf) == 1)
+ if (ut.ut_name[0] != 0
+ && strncmp(user, ut.ut_name, sizeof(ut.ut_name)) == 0) {
+ alert(ut.ut_line, md);
+ }
+ fclose (uf);
#endif /* HAVE_GETUTXENT */
exit(0);
@@ -290,7 +302,6 @@ header_fd (void)
}
-#if HAVE_GETUTXENT
static void
alert (char *tty, int md)
{
@@ -327,4 +338,3 @@ alert (char *tty, int md)
close (td);
}
-#endif /* HAVE_GETUTXENT */