-/* $NetBSD: faketalk.c,v 1.13 2009/07/04 01:01:18 dholland Exp $ */
+/* $NetBSD: faketalk.c,v 1.18 2009/08/27 00:36:33 dholland Exp $ */
/*
* Copyright (c) 1983-2003, Regents of the University of California.
* All rights reserved.
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: faketalk.c,v 1.13 2009/07/04 01:01:18 dholland Exp $");
+__RCSID("$NetBSD: faketalk.c,v 1.18 2009/08/27 00:36:33 dholland Exp $");
#endif /* not lint */
#include "bsd.h"
#include "hunt.h"
-#if defined(TALK_43) || defined(TALK_42)
+#if defined(TALK_43) || defined(TALK_42)
-# include <sys/time.h>
-# include <sys/wait.h>
-# include <ctype.h>
-# include <netdb.h>
-# include <signal.h>
-# include <stdio.h>
-# include <string.h>
-# include <unistd.h>
-# include "talk_ctl.h"
+#include <sys/time.h>
+#include <sys/wait.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <signal.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include "talk_ctl.h"
-# define TRUE 1
-# define FALSE 0
+#define TRUE 1
+#define FALSE 0
/* defines for fake talk message to announce start of game */
-# ifdef TALK_43
-# define MASQUERADE "\"Hunt Game\""
-# else
-# define MASQUERADE "HuntGame"
-# endif
-# define RENDEZVOUS "hunt-players"
-# define ARGV0 "HUNT-ANNOUNCE"
-
-extern char *my_machine_name;
-extern char *First_arg, *Last_arg;
-extern char **environ;
-
-static void do_announce(char *);
-SIGNAL_TYPE exorcise(int);
+#ifdef TALK_43
+#define MASQUERADE "\"Hunt Game\""
+#else
+#define MASQUERADE "HuntGame"
+#endif
+#define RENDEZVOUS "hunt-players"
+#define ARGV0 "HUNT-ANNOUNCE"
+
+extern char *my_machine_name;
+extern char *First_arg, *Last_arg;
+extern char **environ;
+
+static void do_announce(char *);
+void exorcise(int);
+
/*
- * exorcise - disspell zombies
+ * exorcise - disspell zombies
*/
-SIGNAL_TYPE
-exorcise(dummy)
- int dummy __unused;
+void
+exorcise(int dummy __unused)
{
(void) wait(0);
}
/*
- * query the local SMTP daemon to expand the RENDEZVOUS mailing list
- * and fake a talk request to each address thus found.
+ * query the local SMTP daemon to expand the RENDEZVOUS mailing list
+ * and fake a talk request to each address thus found.
*/
void
-faketalk()
+faketalk(void)
{
- struct servent *sp;
- char buf[BUFSIZ];
- FILE *f;
- int service; /* socket of service */
- struct sockaddr_in des; /* address of destination */
- char *a, *b;
+ struct servent *sp;
+ char buf[BUFSIZ];
+ FILE *f;
+ int service; /* socket of service */
+ struct sockaddr_in des; /* address of destination */
+ char *a, *b;
(void) signal(SIGCHLD, exorcise);
(void) signal(SIGPIPE, SIG_IGN);
/*
- * change argv so that a ps shows ARGV0
+ * change argv so that a ps shows ARGV0
*/
*environ = NULL;
for (a = First_arg, b = ARGV0; a < Last_arg; a++) {
*/
if ((sp = getservbyname("smtp", NULL)) == NULL) {
-# ifdef LOG
+#ifdef LOG
syslog(LOG_ERR, "faketalk: smtp protocol not supported\n");
-# else
+#else
warn("faketalk: stmp protocol not supported");
-# endif
+#endif
_exit(1);
}
des.sin_port = sp->s_port;
if ((service = socket(des.sin_family, SOCK_STREAM, 0)) < 0) {
-# ifdef LOG
+#ifdef LOG
syslog(LOG_ERR, "falktalk: socket");
-# else
+#else
warn("falktalk: socket");
-# endif
+#endif
_exit(1);
}
if (connect(service, (struct sockaddr *) &des, sizeof(des)) != 0) {
-# ifdef LOG
+#ifdef LOG
syslog(LOG_ERR, "faketalk: connect");
-# else
+#else
warn("faketalk: connect");
-# endif
+#endif
_exit(1);
}
if ((f = fdopen(service, "r")) == NULL) {
-# ifdef LOG
+#ifdef LOG
syslog(LOG_ERR, "fdopen failed\n");
-# else
+#else
warn("faketalk: fdopen");
-# endif
+#endif
_exit(2);
}
"EXPN %s@%s\r\n", RENDEZVOUS, my_machine_name);
(void) write(service, buf, strlen(buf));
while (fgets(buf, BUFSIZ, f) != NULL) {
- char *s, *t;
+ char *s, *t;
if (buf[0] != '2' || buf[1] != '5' || buf[2] != '0')
break;
*/
static void
-do_announce(s)
- char *s;
+do_announce(char *s)
{
- CTL_RESPONSE response;
+ CTL_RESPONSE response;
get_remote_name(s); /* setup his_machine_addr, msg.r_name */
-# ifdef TALK_43
-# if BSD_RELEASE >= 44
+#ifdef TALK_43
msg.ctl_addr = *(struct osockaddr *) &ctl_addr;
-# else
- msg.ctl_addr = *(struct sockaddr *) &ctl_addr;
-# endif
msg.ctl_addr.sa_family = htons(msg.ctl_addr.sa_family);
-# else
+#else
msg.ctl_addr = ctl_addr;
msg.ctl_addr.sin_family = htons(msg.ctl_addr.sin_family);
-# endif
- msg.id_num = (int) htonl((u_int32_t) -1); /* an impossible id_num */
+#endif
+ msg.id_num = (int) htonl((uint32_t) -1); /* an impossible id_num */
ctl_transact(his_machine_addr, msg, ANNOUNCE, &response);
if (response.answer != SUCCESS)
return;
!= sizeof(msg))
p_error("send delete remote");
}
+
#else
+
void
-faketalk()
+faketalk(void)
{
return;
}
+
#endif