Added basic irc ideas
This commit is contained in:
parent
167e9eb184
commit
79ba3b3c47
14
configure
vendored
14
configure
vendored
@ -841,6 +841,7 @@ if test -n "$ac_init_help"; then
|
|||||||
Optional Features:
|
Optional Features:
|
||||||
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
||||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||||
|
--enable-experiment Compile experimental code
|
||||||
--enable-debugging Compile for debugging
|
--enable-debugging Compile for debugging
|
||||||
--enable-optimize Enable CPU optimize
|
--enable-optimize Enable CPU optimize
|
||||||
--enable-newsgate Compile with newsgate
|
--enable-newsgate Compile with newsgate
|
||||||
@ -2989,6 +2990,19 @@ esac
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Check whether --enable-experiment or --disable-experiment was given.
|
||||||
|
if test "${enable_experiment+set}" = set; then
|
||||||
|
enableval="$enable_experiment"
|
||||||
|
experiment=$enableval
|
||||||
|
else
|
||||||
|
experiment=no
|
||||||
|
fi;
|
||||||
|
if test "$experiment" = "yes"; then
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define USE_EXPERIMENT 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# Check whether --enable-debugging or --disable-debugging was given.
|
# Check whether --enable-debugging or --disable-debugging was given.
|
||||||
if test "${enable_debugging+set}" = set; then
|
if test "${enable_debugging+set}" = set; then
|
||||||
|
@ -67,10 +67,10 @@ AC_C_BIGENDIAN
|
|||||||
dnl
|
dnl
|
||||||
dnl Additional commandline switches
|
dnl Additional commandline switches
|
||||||
dnl
|
dnl
|
||||||
dnl AC_ARG_ENABLE(experiment, [ --enable-experiment Compile experimental code], [ experiment=$enableval ], [ experiment=no ])
|
AC_ARG_ENABLE(experiment, [ --enable-experiment Compile experimental code], [ experiment=$enableval ], [ experiment=no ])
|
||||||
dnl if test "$experiment" = "yes"; then
|
if test "$experiment" = "yes"; then
|
||||||
dnl AC_DEFINE(USE_EXPERIMENT)
|
AC_DEFINE(USE_EXPERIMENT)
|
||||||
dnl fi
|
fi
|
||||||
|
|
||||||
AC_ARG_ENABLE(debugging, [ --enable-debugging Compile for debugging], [ debugging=$enableval ], [ debugging=no ])
|
AC_ARG_ENABLE(debugging, [ --enable-debugging Compile for debugging], [ debugging=$enableval ], [ debugging=no ])
|
||||||
if test "$debugging" = "yes"; then
|
if test "$debugging" = "yes"; then
|
||||||
|
@ -2029,6 +2029,27 @@ struct _route {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IRC servers to connect to.
|
||||||
|
*/
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
struct _ircsrvhdr {
|
||||||
|
long hdrsize; /* Size of header */
|
||||||
|
long recsize; /* Size of record */
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct _ircsrv {
|
||||||
|
char server[64]; /* Peer server name */
|
||||||
|
char passwd[16]; /* Password */
|
||||||
|
unsigned Active : 1; /* Is server active */
|
||||||
|
unsigned Deleted : 1; /* Must server be deleted */
|
||||||
|
unsigned Compress : 1; /* Use compresssion */
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* From clcomm.c
|
* From clcomm.c
|
||||||
*/
|
*/
|
||||||
@ -2642,5 +2663,10 @@ struct _scanmgr scanmgr;
|
|||||||
struct _routehdr routehdr; /* Routing file */
|
struct _routehdr routehdr; /* Routing file */
|
||||||
struct _route route;
|
struct _route route;
|
||||||
|
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
struct _ircsrvhdr ircsrvhdr; /* IRC servers */
|
||||||
|
struct _ircsrv ircsrv;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
|
|
||||||
include ../Makefile.global
|
include ../Makefile.global
|
||||||
|
|
||||||
SRCS = callstat.c scanout.c taskcomm.c taskinfo.c taskstat.c \
|
SRCS = callstat.c scanout.c taskcomm.c taskinfo.c taskstat.c taskirc.c \
|
||||||
mbtask.c outstat.c signame.c taskdisk.c taskregs.c taskutil.c \
|
mbtask.c outstat.c signame.c taskdisk.c taskregs.c taskutil.c \
|
||||||
ports.c calllist.c ping.c taskchat.c crc.c
|
ports.c calllist.c ping.c taskchat.c crc.c
|
||||||
HDRS = callstat.h mbtask.h outstat.h signame.h taskdisk.h taskregs.h taskutil.h \
|
HDRS = callstat.h mbtask.h outstat.h signame.h taskdisk.h taskregs.h taskutil.h \
|
||||||
scanout.h taskcomm.h taskinfo.h taskstat.h \
|
scanout.h taskcomm.h taskinfo.h taskstat.h taskirc.h \
|
||||||
ports.h calllist.h ping.h taskchat.h
|
ports.h calllist.h ping.h taskchat.h
|
||||||
OBJS = callstat.o scanout.o taskcomm.o taskinfo.o taskstat.o \
|
OBJS = callstat.o scanout.o taskcomm.o taskinfo.o taskstat.o taskirc.o \
|
||||||
mbtask.o outstat.o signame.o taskdisk.o taskregs.o taskutil.o \
|
mbtask.o outstat.o signame.o taskdisk.o taskregs.o taskutil.o \
|
||||||
ports.o calllist.o ping.o taskchat.o crc.o
|
ports.o calllist.o ping.o taskchat.o crc.o
|
||||||
SLIBS = ../lib/libnodelist.a
|
SLIBS = ../lib/libnodelist.a
|
||||||
@ -73,7 +73,8 @@ scanout.o: ../config.h ../lib/mbselib.h taskutil.h scanout.h
|
|||||||
taskcomm.o: ../config.h ../lib/mbselib.h taskstat.h taskregs.h taskdisk.h taskinfo.h taskutil.h taskchat.h taskcomm.h
|
taskcomm.o: ../config.h ../lib/mbselib.h taskstat.h taskregs.h taskdisk.h taskinfo.h taskutil.h taskchat.h taskcomm.h
|
||||||
taskinfo.o: ../config.h ../lib/mbselib.h taskinfo.h
|
taskinfo.o: ../config.h ../lib/mbselib.h taskinfo.h
|
||||||
taskstat.o: ../config.h ../lib/mbselib.h taskstat.h callstat.h outstat.h taskutil.h
|
taskstat.o: ../config.h ../lib/mbselib.h taskstat.h callstat.h outstat.h taskutil.h
|
||||||
mbtask.o: ../config.h ../lib/mbselib.h ../paths.h signame.h taskstat.h taskutil.h taskregs.h taskcomm.h taskdisk.h callstat.h outstat.h ../lib/nodelist.h ports.h calllist.h ping.h taskchat.h mbtask.h
|
taskirc.o: ../config.h ../lib/mbselib.h taskirc.h
|
||||||
|
mbtask.o: ../config.h ../lib/mbselib.h ../paths.h signame.h taskstat.h taskutil.h taskregs.h taskcomm.h taskdisk.h taskirc.h callstat.h outstat.h ../lib/nodelist.h ports.h calllist.h ping.h taskchat.h mbtask.h
|
||||||
outstat.o: ../config.h ../lib/mbselib.h taskutil.h taskstat.h scanout.h ../lib/nodelist.h callstat.h ports.h outstat.h
|
outstat.o: ../config.h ../lib/mbselib.h taskutil.h taskstat.h scanout.h ../lib/nodelist.h callstat.h ports.h outstat.h
|
||||||
signame.o: ../config.h signame.h
|
signame.o: ../config.h signame.h
|
||||||
taskdisk.o: ../config.h ../lib/mbselib.h taskdisk.h taskutil.h
|
taskdisk.o: ../config.h ../lib/mbselib.h taskdisk.h taskutil.h
|
||||||
@ -82,6 +83,6 @@ taskutil.o: ../config.h ../lib/mbselib.h signame.h scanout.h taskutil.h
|
|||||||
ports.o: ../config.h ../lib/mbselib.h taskutil.h ../lib/nodelist.h ports.h
|
ports.o: ../config.h ../lib/mbselib.h taskutil.h ../lib/nodelist.h ports.h
|
||||||
calllist.o: ../config.h ../lib/mbselib.h taskstat.h taskutil.h callstat.h outstat.h mbtask.h calllist.h
|
calllist.o: ../config.h ../lib/mbselib.h taskstat.h taskutil.h callstat.h outstat.h mbtask.h calllist.h
|
||||||
ping.o: ../config.h ../lib/mbselib.h taskstat.h taskutil.h ping.h
|
ping.o: ../config.h ../lib/mbselib.h taskstat.h taskutil.h ping.h
|
||||||
taskchat.o: ../config.h ../lib/mbselib.h taskutil.h taskregs.h taskchat.h
|
taskchat.o: ../config.h ../lib/mbselib.h taskutil.h taskregs.h taskchat.h taskirc.h
|
||||||
crc.o: ../config.h ../lib/mbselib.h
|
crc.o: ../config.h ../lib/mbselib.h
|
||||||
# End of generated dependencies
|
# End of generated dependencies
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "taskregs.h"
|
#include "taskregs.h"
|
||||||
#include "taskcomm.h"
|
#include "taskcomm.h"
|
||||||
#include "taskdisk.h"
|
#include "taskdisk.h"
|
||||||
|
#include "taskirc.h"
|
||||||
#include "callstat.h"
|
#include "callstat.h"
|
||||||
#include "outstat.h"
|
#include "outstat.h"
|
||||||
#include "../lib/nodelist.h"
|
#include "../lib/nodelist.h"
|
||||||
@ -47,8 +48,6 @@
|
|||||||
#include "mbtask.h"
|
#include "mbtask.h"
|
||||||
|
|
||||||
|
|
||||||
#define NUM_THREADS 4 /* Max. nr of threads */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Global variables
|
* Global variables
|
||||||
@ -116,7 +115,9 @@ extern int cmd_run; /* Cmd running */
|
|||||||
extern int ping_run; /* Ping running */
|
extern int ping_run; /* Ping running */
|
||||||
int sched_run = FALSE; /* Scheduler running */
|
int sched_run = FALSE; /* Scheduler running */
|
||||||
extern int disk_run; /* Disk watch running */
|
extern int disk_run; /* Disk watch running */
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
extern int irc_run; /* IRC thread running */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -126,7 +127,9 @@ pthread_t pt_ping;
|
|||||||
pthread_t pt_command;
|
pthread_t pt_command;
|
||||||
pthread_t pt_disk;
|
pthread_t pt_disk;
|
||||||
pthread_t pt_scheduler;
|
pthread_t pt_scheduler;
|
||||||
// pthread_t p_thread[NUM_THREADS]; /* thread's structure */
|
#ifdef USE_EXPERIMENT
|
||||||
|
pthread_t pt_irc;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -742,10 +745,18 @@ void die(int onsig)
|
|||||||
* build to stop within a second.
|
* build to stop within a second.
|
||||||
*/
|
*/
|
||||||
now = time(NULL) + 2;
|
now = time(NULL) + 2;
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
while ((cmd_run || ping_run || sched_run || disk_run || irc_run) && (time(NULL) < now)) {
|
||||||
|
#else
|
||||||
while ((cmd_run || ping_run || sched_run || disk_run) && (time(NULL) < now)) {
|
while ((cmd_run || ping_run || sched_run || disk_run) && (time(NULL) < now)) {
|
||||||
|
#endif
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
if (cmd_run || ping_run || sched_run || disk_run || irc_run)
|
||||||
|
#else
|
||||||
if (cmd_run || ping_run || sched_run || disk_run)
|
if (cmd_run || ping_run || sched_run || disk_run)
|
||||||
|
#endif
|
||||||
Syslog('+', "Not all threads stopped! Forced shutdown");
|
Syslog('+', "Not all threads stopped! Forced shutdown");
|
||||||
else
|
else
|
||||||
Syslog('+', "All threads stopped");
|
Syslog('+', "All threads stopped");
|
||||||
@ -1036,6 +1047,11 @@ void start_scheduler(void)
|
|||||||
} else if ((rc = pthread_create(&pt_scheduler, NULL, (void (*))scheduler, NULL))) {
|
} else if ((rc = pthread_create(&pt_scheduler, NULL, (void (*))scheduler, NULL))) {
|
||||||
WriteError("$pthread_create scheduler rc=%d", rc);
|
WriteError("$pthread_create scheduler rc=%d", rc);
|
||||||
die(SIGTERM);
|
die(SIGTERM);
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
} else if ((rc = pthread_create(&pt_irc, NULL, (void (*))irc_thread, NULL))) {
|
||||||
|
WriteError("$pthread_create irc rc=%d", rc);
|
||||||
|
die(SIGTERM);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
Syslog('+', "All threads installed");
|
Syslog('+', "All threads installed");
|
||||||
}
|
}
|
||||||
|
@ -347,9 +347,6 @@ printf("Start ping thread\n");
|
|||||||
|
|
||||||
while (! T_Shutdown) {
|
while (! T_Shutdown) {
|
||||||
|
|
||||||
#ifdef USE_EXPERMIMENT
|
|
||||||
Syslog('p', "ping_thread loop start");
|
|
||||||
#endif
|
|
||||||
/*
|
/*
|
||||||
* Select new address to ping
|
* Select new address to ping
|
||||||
*/
|
*/
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#include "taskutil.h"
|
#include "taskutil.h"
|
||||||
#include "taskregs.h"
|
#include "taskregs.h"
|
||||||
#include "taskchat.h"
|
#include "taskchat.h"
|
||||||
|
#include "taskirc.h"
|
||||||
|
|
||||||
|
|
||||||
#define MAXCHANNELS 10 /* Maximum chat channels */
|
#define MAXCHANNELS 10 /* Maximum chat channels */
|
||||||
#define MAXMESSAGES 100 /* Maximum ringbuffer for messages */
|
#define MAXMESSAGES 100 /* Maximum ringbuffer for messages */
|
||||||
@ -123,7 +125,6 @@ int part(pid_t, char*);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void chat_dump(void)
|
void chat_dump(void)
|
||||||
{
|
{
|
||||||
int i, first;
|
int i, first;
|
||||||
@ -371,6 +372,10 @@ void chat_msg(int channel, char *nick, char *msg)
|
|||||||
system_msg(chat_users[i].pid, buf);
|
system_msg(chat_users[i].pid, buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
send_all(buf);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
136
mbtask/taskirc.c
Normal file
136
mbtask/taskirc.c
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* $Id$
|
||||||
|
* Purpose ...............: mbtask - Internet Realy Chat (sort of)
|
||||||
|
*
|
||||||
|
*****************************************************************************
|
||||||
|
* Copyright (C) 1997-2005
|
||||||
|
*
|
||||||
|
* Michiel Broek FIDO: 2:280/2802
|
||||||
|
* Beekmansbos 10
|
||||||
|
* 1971 BV IJmuiden
|
||||||
|
* the Netherlands
|
||||||
|
*
|
||||||
|
* This file is part of MBSE BBS.
|
||||||
|
*
|
||||||
|
* This BBS is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation; either version 2, or (at your option) any
|
||||||
|
* later version.
|
||||||
|
*
|
||||||
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
||||||
|
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#include "../config.h"
|
||||||
|
#include "../lib/mbselib.h"
|
||||||
|
#include "taskirc.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
|
||||||
|
int irc_run = FALSE; /* Thread running */
|
||||||
|
extern int T_Shutdown; /* Program shutdown */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send a UDP message to one other server.
|
||||||
|
*/
|
||||||
|
void send_server(char *name, char *msg)
|
||||||
|
{
|
||||||
|
int a1, a2, a3, a4;
|
||||||
|
int s; /* Socket */
|
||||||
|
struct hostent *he; /* Host info */
|
||||||
|
struct servent *se; /* Service information */
|
||||||
|
struct sockaddr_in server; /* Destination address */
|
||||||
|
char *errmsg;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get IP address for the hostname
|
||||||
|
*/
|
||||||
|
if (sscanf(name,"%d.%d.%d.%d",&a1,&a2,&a3,&a4) == 4)
|
||||||
|
server.sin_addr.s_addr = inet_addr(name);
|
||||||
|
else if ((he = gethostbyname(name)))
|
||||||
|
memcpy(&server.sin_addr,he->h_addr,he->h_length);
|
||||||
|
else {
|
||||||
|
switch (h_errno) {
|
||||||
|
case HOST_NOT_FOUND: errmsg = (char *)"Authoritative: Host not found"; break;
|
||||||
|
case TRY_AGAIN: errmsg = (char *)"Non-Authoritive: Host not found"; break;
|
||||||
|
case NO_RECOVERY: errmsg = (char *)"Non recoverable errors"; break;
|
||||||
|
default: errmsg = (char *)"Unknown error"; break;
|
||||||
|
}
|
||||||
|
Syslog('+', "No IP address for %s: %s", name, errmsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
se = getservbyname("fido", "udp");
|
||||||
|
if (se == NULL) {
|
||||||
|
Syslog('n', "Service fido udp not in /etc/services");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
server.sin_family = AF_INET;
|
||||||
|
server.sin_port = se->s_port;
|
||||||
|
|
||||||
|
Syslog('r', "Send to %s, port %d\n", inet_ntoa(server.sin_addr), ntohs(server.sin_port));
|
||||||
|
|
||||||
|
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (s == -1) {
|
||||||
|
Syslog('r', "$Can't create socket");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bind(s, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) == -1) {
|
||||||
|
Syslog('r', "$Can't bind socket");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sendto(s, msg, strlen(msg), 0, (struct sockaddr *)&server, sizeof(struct sockaddr_in)) == -1) {
|
||||||
|
Syslog('r', "$Can't send message");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Send a message to all servers
|
||||||
|
*/
|
||||||
|
void send_all(char *msg)
|
||||||
|
{
|
||||||
|
send_server((char *)"router.mbse.ym", msg);
|
||||||
|
send_server((char *)"hppa.mbse.ym", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* IRC thread
|
||||||
|
*/
|
||||||
|
void *irc_thread(void *dummy)
|
||||||
|
{
|
||||||
|
Syslog('+', "Starting IRC thread");
|
||||||
|
irc_run = TRUE;
|
||||||
|
|
||||||
|
while (! T_Shutdown) {
|
||||||
|
sleep(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
irc_run = FALSE;
|
||||||
|
Syslog('+', "IRC thread stopped");
|
||||||
|
pthread_exit(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
11
mbtask/taskirc.h
Normal file
11
mbtask/taskirc.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef _TASKIRC_H
|
||||||
|
#define _TASKIRC_H
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
#ifdef USE_EXPERIMENT
|
||||||
|
void send_all(char *);
|
||||||
|
void *irc_thread(void *);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user