+Sun May 28 17:44:15 CEST 2000 Ruud de Rooij <ruud@ruud.org>
+
+ * Added autoconf check for getutent().
+ * Changed uip/rcvtty.c and uip/slocal.c to use getutent() and
+ friends. Since I can only check on Linux, please check if
+ this works on other systems.
+
Sun May 28 14:58:49 CEST 2000 Ruud de Rooij <ruud@ruud.org>
* Applied patch from Peter Maydell to uip/scansbr.c for more
int main() {
/* Ultrix mips cc rejects this. */
-typedef int charset[2]; const charset x;
+typedef int charset[2]; const charset x = {0,0};
/* SunOS 4.1.1 cc rejects this. */
char const *const *ccp;
char **p;
else
echo "$ac_t""no" 1>&6
fi
- for ac_prog in gawk mawk nawk awk
+ for ac_prog in mawk gawk nawk awk
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
for ac_func in waitpid wait3 sigaction sigprocmask sigblock sigsetmask \
sighold sigrelse writev lstat uname tzset killpg mkstemp \
- sethostent
+ sethostent getutent
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2732: checking for $ac_func" >&5
* $Id$
*/
+/* Changed to use getutent() and friends. Assumes that when getutent() exists,
+ * a number of other things also exist. Please check.
+ * Ruud de Rooij <ruud@ruud.org> Sun, 28 May 2000 17:28:55 +0200
+ */
+
#include <h/mh.h>
#include <h/signals.h>
#include <h/rcvmail.h>
#include <fcntl.h>
#include <utmp.h>
-#ifndef UTMP_FILE
-# ifdef _PATH_UTMP
-# define UTMP_FILE _PATH_UTMP
-# else
-# define UTMP_FILE "/etc/utmp"
+
+#ifndef HAVE_GETUTENT
+# ifndef UTMP_FILE
+# ifdef _PATH_UTMP
+# define UTMP_FILE _PATH_UTMP
+# else
+# define UTMP_FILE "/etc/utmp"
+# endif
# endif
#endif
int md, vecp = 0;
char *cp, *user, buf[BUFSIZ], tty[BUFSIZ];
char **argp, **arguments, *vec[MAXARGS];
+#ifdef HAVE_GETUTENT
+ struct utmp * utp;
+#else
struct utmp ut;
register FILE *uf;
+#endif
#ifdef LOCALE
setlocale(LC_ALL, "");
exit (RCV_MBX);
user = getusername();
+
+#ifdef HAVE_GETUTENT
+ setutent();
+ while ((utp = getutent()) != NULL) {
+ if (utp->ut_type == USER_PROCESS
+ && utp->ut_user[0] != 0
+ && utp->ut_line[0] != 0
+ && strncmp (user, utp->ut_user, sizeof(utp->ut_user)) == 0) {
+ strncpy (tty, utp->ut_line, sizeof(utp->ut_line));
+ alert (tty, md);
+ }
+ }
+ endutent();
+#else
if ((uf = fopen (UTMP_FILE, "r")) == NULL)
exit (RCV_MBX);
-
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) {
strncpy (tty, ut.ut_line, sizeof(ut.ut_line));
alert (tty, md);
}
-
fclose (uf);
+#endif
+
exit (RCV_MOK);
return 0; /* dead code to satisfy the compiler */
}
*
*/
+/* Changed to use getutent() and friends. Assumes that when getutent() exists,
+ * a number of other things also exist. Please check.
+ * Ruud de Rooij <ruud@ruud.org> Sun, 28 May 2000 17:28:55 +0200
+ */
+
#include <h/mh.h>
#include <h/dropsbr.h>
#include <h/rcvmail.h>
#include <utmp.h>
-#ifndef UTMP_FILE
-# ifdef _PATH_UTMP
-# define UTMP_FILE _PATH_UTMP
-# else
-# define UTMP_FILE "/etc/utmp"
+#ifndef HAVE_GETUTENT
+# ifndef UTMP_FILE
+# ifdef _PATH_UTMP
+# define UTMP_FILE _PATH_UTMP
+# else
+# define UTMP_FILE "/etc/utmp"
+# endif
# endif
#endif
* logged in.
*/
+#ifdef HAVE_GETUTENT
+static int
+logged_in (void)
+{
+ struct utmp * utp;
+
+ if (utmped)
+ return utmped;
+
+ setutent();
+
+ while ((utp = getutent()) != NULL) {
+ if (utp->ut_type == USER_PROCESS
+ && utp->ut_user[0] != 0
+ && strncmp (user, utp->ut_user, sizeof(utp->ut_user)) == 0) {
+ if (debug)
+ continue;
+ endutent();
+ return (utmped = DONE);
+ }
+ }
+
+ endutent();
+ return (utmped = NOTOK);
+}
+#else
static int
logged_in (void)
{
fclose (uf);
return (utmped = NOTOK);
}
-
+#endif
#define check(t,a,b) if (t < a || t > b) return -1
#define cmpar(h1,m1,h2,m2) if (h1 < h2 || (h1 == h2 && m1 < m2)) return 0