Code cleanup
This commit is contained in:
parent
5fc848598c
commit
bd4581db84
@ -11,7 +11,7 @@ SRCS = zmmisc.c zmrle.c zmrecv.c zmsend.c binkp.c \
|
||||
recvbark.c respfreq.c sendbark.c tcp.c tcpproto.c wazoo.c \
|
||||
filetime.c ftsc.c atoul.c portsel.c \
|
||||
ttyio.c lutil.c scanout.c emsi.c ulock.c \
|
||||
callstat.c session.c call.c callall.c mbcico.c \
|
||||
callstat.c session.c call.c mbcico.c \
|
||||
outstat.c nlinfo.c mbout.c
|
||||
HDRS = zmodem.h binkp.h config.h statetbl.h \
|
||||
xmsend.h xmrecv.h m7recv.h m7send.h hydra.h \
|
||||
@ -20,7 +20,7 @@ HDRS = zmodem.h binkp.h config.h statetbl.h \
|
||||
recvbark.h respfreq.h sendbark.h tcp.h tcpproto.h wazoo.h \
|
||||
filetime.h ftsc.h atoul.h portsel.h \
|
||||
ttyio.h lutil.h scanout.h emsi.h ulock.h \
|
||||
callstat.h session.h call.h callall.h mbcico.h \
|
||||
callstat.h session.h call.h mbcico.h \
|
||||
outstat.h nlinfo.h
|
||||
MBCICO_OBJS = zmmisc.o zmrle.o zmrecv.o zmsend.o binkp.o \
|
||||
xmsend.o xmrecv.o m7recv.o m7send.o hydra.o \
|
||||
@ -29,7 +29,7 @@ MBCICO_OBJS = zmmisc.o zmrle.o zmrecv.o zmsend.o binkp.o \
|
||||
recvbark.o respfreq.o sendbark.o tcp.o tcpproto.o wazoo.o \
|
||||
filetime.o ftsc.o atoul.o portsel.o \
|
||||
ttyio.o lutil.o scanout.o emsi.o ulock.o \
|
||||
callstat.o session.o call.o callall.o mbcico.o
|
||||
callstat.o session.o call.o mbcico.o
|
||||
MBOUT_OBJS = outstat.o nlinfo.o mbout.o scanout.o callstat.o
|
||||
LIBS += ../lib/libmemwatch.a ../lib/libclcomm.a ../lib/libcommon.a ../lib/libmsgbase.a ../lib/libdbase.a
|
||||
OTHER = Makefile README
|
||||
@ -97,15 +97,15 @@ m7recv.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h statetb
|
||||
m7send.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h statetbl.h ttyio.h m7send.h
|
||||
hydra.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h session.h filelist.h filetime.h ttyio.h statetbl.h config.h emsi.h openfile.h lutil.h respfreq.h mbcico.h hydra.h
|
||||
answer.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h lutil.h session.h config.h answer.h openport.h portsel.h dial.h rdoptions.h mbcico.h
|
||||
chat.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h config.h portsel.h chat.h ttyio.h
|
||||
dial.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h portsel.h config.h chat.h ttyio.h session.h dial.h
|
||||
chat.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h config.h chat.h ttyio.h
|
||||
dial.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h config.h chat.h ttyio.h session.h dial.h
|
||||
dietifna.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h emsi.h dietifna.h respfreq.h filelist.h xmrecv.h xmsend.h
|
||||
emsidat.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h emsi.h session.h lutil.h config.h emsidat.h filetime.h
|
||||
filelist.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h config.h session.h filelist.h
|
||||
openfile.o: ../lib/libs.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h config.h lutil.h openfile.h
|
||||
openport.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ulock.h ttyio.h openport.h
|
||||
opentcp.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h session.h ttyio.h openport.h opentcp.h
|
||||
rdoptions.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h portsel.h session.h config.h
|
||||
rdoptions.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h session.h config.h
|
||||
yoohoo.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/dbnode.h statetbl.h ttyio.h session.h config.h emsi.h hydra.h rdoptions.h wazoo.h dietifna.h yoohoo.h
|
||||
recvbark.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h statetbl.h recvbark.h respfreq.h filelist.h
|
||||
respfreq.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h session.h lutil.h config.h atoul.h respfreq.h filelist.h
|
||||
@ -125,8 +125,7 @@ ulock.o: ../lib/libs.h ../lib/clcomm.h
|
||||
callstat.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h callstat.h
|
||||
session.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ttyio.h statetbl.h emsi.h ftsc.h session.h yoohoo.h mbcico.h binkp.h callstat.h
|
||||
call.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h session.h callstat.h call.h config.h dial.h lutil.h portsel.h openport.h opentcp.h rdoptions.h
|
||||
callall.o: ../lib/libs.h ../lib/structs.h ../lib/common.h config.h ../lib/clcomm.h scanout.h lutil.h callstat.h callall.h
|
||||
mbcico.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h config.h answer.h portsel.h call.h callall.h lutil.h mbcico.h session.h
|
||||
mbcico.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h config.h answer.h call.h lutil.h mbcico.h session.h
|
||||
outstat.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h scanout.h callstat.h outstat.h
|
||||
nlinfo.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h nlinfo.h
|
||||
mbout.o: ../lib/libs.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h outstat.h nlinfo.h
|
||||
|
@ -71,7 +71,6 @@ int portopen(faddr *addr)
|
||||
{
|
||||
char *p;
|
||||
int rc;
|
||||
pp_list *pl = NULL, *tmp;
|
||||
|
||||
if (inetaddr) {
|
||||
Syslog('d', "portopen inetaddr %s", inetaddr);
|
||||
@ -104,30 +103,6 @@ int portopen(faddr *addr)
|
||||
}
|
||||
|
||||
WriteError("call.c portopen(): should not be here");
|
||||
|
||||
if (make_portlist(nlent, &pl) == 0) {
|
||||
WriteError("No matching ports defined");
|
||||
nodeulock(addr);
|
||||
putstatus(addr, 10, ST_NOPORT);
|
||||
return ST_NOPORT;
|
||||
}
|
||||
|
||||
for (tmp = pl; tmp; tmp = tmp->next) {
|
||||
if (load_port(tmp->tty)) {
|
||||
Syslog('+', "Port %s at %ld, modem %s", ttyinfo.tty, ttyinfo.portspeed, modem.modem);
|
||||
p = xstrcpy(tmp->tty);
|
||||
rc = openport(p, ttyinfo.portspeed);
|
||||
free(p);
|
||||
if (rc == 0) {
|
||||
tidy_pplist(&pl);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tidy_pplist(&pl);
|
||||
nodeulock(addr);
|
||||
putstatus(addr, 0, ST_PORTERR);
|
||||
return ST_PORTERR;
|
||||
}
|
||||
|
||||
@ -250,12 +225,6 @@ int call(faddr *addr)
|
||||
}
|
||||
|
||||
if (((nlent->oflags & OL_CM) == 0) && (!IsZMH())) {
|
||||
// if (!forcedcalls) {
|
||||
// Syslog('d', "Node is ZMH only and it is not ZMH");
|
||||
// nodeulock(addr);
|
||||
// putstatus(addr,0,ST_NOTZMH);
|
||||
// return ST_NOTZMH;
|
||||
// }
|
||||
Syslog('?', "Warning: calling MO system outside ZMH");
|
||||
}
|
||||
|
||||
@ -269,26 +238,6 @@ int call(faddr *addr)
|
||||
* Over TCP/IP we don't do a delay because the node we are
|
||||
* connecting can't be busy. Also forced calls don't delay.
|
||||
*/
|
||||
// Syslog('d', "delay=%d inetaddr=%s immediatecall=%s",
|
||||
// CFG.dialdelay, inetaddr?"true":"false", immediatecall?"true":"false");
|
||||
// if ((CFG.dialdelay > 10) && (!inetaddr) && (!immediatecall)) {
|
||||
// /*
|
||||
// * Generate a random number between CFG.dialdelay and
|
||||
// * CFG.dialdelay / 10, minimum value is 10.
|
||||
// */
|
||||
// srand(getpid());
|
||||
// while (TRUE) {
|
||||
// j = 1+(int) (1.0 * CFG.dialdelay * rand() / (RAND_MAX + 1.0));
|
||||
// if ((j > (CFG.dialdelay / 10)) && (j > 9))
|
||||
// break;
|
||||
// }
|
||||
// Syslog('d', "Dial delay %d seconds", j);
|
||||
//
|
||||
// for (i = j; i > 0; i--) {
|
||||
// IsDoing("Delay %d seconds", i);
|
||||
// sleep(1);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (nodelock(addr)) {
|
||||
Syslog('+', "System %s is locked", ascfnode(addr, 0x1f));
|
||||
@ -308,8 +257,8 @@ int call(faddr *addr)
|
||||
* and
|
||||
* nocall is false
|
||||
*/
|
||||
if ((nlent->phone || forcedphone || inetaddr ) && ((forcedcalls || (nlent->oflags & OL_CM)) ||
|
||||
(((nlent->pflag & (NL_DUMMY|NL_DOWN|NL_HOLD|NL_PVT)) == 0) && ((localoptions & NOCALL) == 0)))) {
|
||||
if ((nlent->phone || forcedphone || inetaddr ) &&
|
||||
(forcedcalls || (((nlent->pflag & (NL_DUMMY|NL_DOWN|NL_HOLD|NL_PVT)) == 0) && ((localoptions & NOCALL) == 0)))) {
|
||||
Syslog('+', "Calling %s (%s, phone %s)",ascfnode(addr,0x1f), nlent->name,nlent->phone?nlent->phone:forcedphone);
|
||||
IsDoing("Call %s", ascfnode(addr, 0x0f));
|
||||
rc = portopen(addr);
|
||||
|
146
mbcico/callall.c
146
mbcico/callall.c
@ -1,146 +0,0 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* File ..................: mbcico/callall.c
|
||||
* Purpose ...............: Fidonet mailer
|
||||
* Last modification date : 27-Nov-2000
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2000
|
||||
*
|
||||
* 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 "../lib/libs.h"
|
||||
#include "../lib/structs.h"
|
||||
#include "../lib/common.h"
|
||||
#include "config.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "scanout.h"
|
||||
#include "lutil.h"
|
||||
#include "callstat.h"
|
||||
#include "callall.h"
|
||||
|
||||
|
||||
static int each(faddr*, char, int, char*);
|
||||
static fa_list *alist = NULL;
|
||||
|
||||
|
||||
|
||||
fa_list *callall(void)
|
||||
{
|
||||
fa_list *tmp;
|
||||
int rc;
|
||||
|
||||
if (alist) {
|
||||
for (tmp = alist; tmp; tmp = alist) {
|
||||
alist = tmp->next;
|
||||
tidy_faddr(tmp->addr);
|
||||
free(tmp);
|
||||
}
|
||||
alist = NULL;
|
||||
}
|
||||
|
||||
if ((rc = scanout(each))) {
|
||||
WriteError("Error scanning outbound, aborting");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (fa_list *)alist;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int each(faddr *addr, char flavor, int isflo, char *fname)
|
||||
{
|
||||
fa_list **tmp;
|
||||
callstat *st;
|
||||
|
||||
if ((flavor == 'h') ||
|
||||
((isflo != OUT_PKT) && (isflo != OUT_FLO) && (isflo != OUT_POL)))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Outside Zone Mail Hour normal flavor will be hold.
|
||||
*/
|
||||
if (!IsZMH() && (flavor == 'o'))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* During ZMH only poll and .pkt files will be sent, except
|
||||
* IMMediate mail, that goes always.
|
||||
*/
|
||||
if (flavor != 'i') {
|
||||
if (IsZMH() && (isflo == OUT_FLO))
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't add nodes who are undiable
|
||||
*/
|
||||
st = getstatus(addr);
|
||||
if (st->tryno >= 30)
|
||||
return 0;
|
||||
|
||||
for (tmp = &alist; *tmp; tmp=&((*tmp)->next))
|
||||
if (((*tmp)->addr->zone == addr->zone) &&
|
||||
((*tmp)->addr->net == addr->net) &&
|
||||
((*tmp)->addr->node == addr->node) &&
|
||||
((*tmp)->addr->point == addr->point) &&
|
||||
(((*tmp)->addr->domain == NULL) ||
|
||||
(addr->domain == NULL) ||
|
||||
(strcasecmp((*tmp)->addr->domain,addr->domain) == 0)))
|
||||
break;
|
||||
|
||||
if (*tmp == NULL) {
|
||||
*tmp=(fa_list *)malloc(sizeof(fa_list));
|
||||
(*tmp)->next=NULL;
|
||||
(*tmp)->addr=(faddr *)malloc(sizeof(faddr));
|
||||
(*tmp)->addr->name=NULL;
|
||||
(*tmp)->addr->zone=addr->zone;
|
||||
(*tmp)->addr->net=addr->net;
|
||||
(*tmp)->addr->node=addr->node;
|
||||
(*tmp)->addr->point=addr->point;
|
||||
(*tmp)->addr->domain=xstrcpy(addr->domain);
|
||||
if (flavor == 'i')
|
||||
(*tmp)->force = TRUE;
|
||||
else
|
||||
(*tmp)->force = FALSE;
|
||||
if (isflo == OUT_POL)
|
||||
(*tmp)->force = TRUE;
|
||||
|
||||
switch (flavor) {
|
||||
case 'i': Syslog('+', "Immediate mail to %s", ascfnode((*tmp)->addr,0x1f));
|
||||
break;
|
||||
case 'c': Syslog('+', "Crash mail to %s", ascfnode((*tmp)->addr,0x1f));
|
||||
break;
|
||||
case 'o': Syslog('+', "Normal mail to %s",ascfnode((*tmp)->addr,0x1f));
|
||||
break;
|
||||
case 'p': Syslog('+', "Poll request to %s",ascfnode((*tmp)->addr,0x1f));
|
||||
break;
|
||||
default : Syslog('+', "Some mail (%c) to %s",flavor,ascfnode((*tmp)->addr,0x1f));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
#ifndef _CALLALL_H
|
||||
#define _CALLALL_H
|
||||
|
||||
|
||||
fa_list *callall(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "../lib/common.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "config.h"
|
||||
#include "portsel.h"
|
||||
#include "chat.h"
|
||||
#include "ttyio.h"
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "../lib/common.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "../lib/dbnode.h"
|
||||
#include "portsel.h"
|
||||
#include "config.h"
|
||||
#include "chat.h"
|
||||
#include "ttyio.h"
|
||||
|
@ -39,9 +39,7 @@
|
||||
#include "../lib/dbftn.h"
|
||||
#include "config.h"
|
||||
#include "answer.h"
|
||||
#include "portsel.h"
|
||||
#include "call.h"
|
||||
#include "callall.h"
|
||||
#include "lutil.h"
|
||||
#include "mbcico.h"
|
||||
#include "session.h"
|
||||
@ -82,7 +80,6 @@ void usage(void)
|
||||
fprintf(stderr,"ifcico; (c) Eugene G. Crosser, 1993-1997\n");
|
||||
fprintf(stderr,"mbcico ver. %s; (c) %s\n\n", VERSION, SHORTRIGHT);
|
||||
fprintf(stderr,"-r<role> -a<inetaddr> <node> ...\n");
|
||||
fprintf(stderr,"-r 0|1 1 - master, 0 - slave [0]\n");
|
||||
fprintf(stderr,"-n<phone> forced phone number\n");
|
||||
fprintf(stderr,"-l<ttydevice> forced tty device\n");
|
||||
fprintf(stderr,"-t<tcpmode> must be one of ifc|itn|ibn, forces TCP/IP\n");
|
||||
@ -201,8 +198,7 @@ int main(int argc, char *argv[])
|
||||
* Catch all signals we can, and handle the rest.
|
||||
*/
|
||||
for (i = 0; i < NSIG; i++) {
|
||||
if ((i == SIGINT) || (i == SIGBUS) ||
|
||||
(i == SIGFPE) || (i == SIGSEGV)) {
|
||||
if ((i == SIGINT) || (i == SIGBUS) || (i == SIGFPE) || (i == SIGSEGV)) {
|
||||
signal(i, (void (*))die);
|
||||
} else
|
||||
signal(i, SIG_DFL);
|
||||
@ -242,12 +238,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
while ((c=getopt(argc,argv,"r:n:l:t:a:I:h")) != -1)
|
||||
switch (c) {
|
||||
case 'r': master = atoi(optarg);
|
||||
if ((master != 0) && (master != 1)) {
|
||||
usage();
|
||||
die(101);
|
||||
}
|
||||
WriteError("commandline option -r is obsolete");
|
||||
case 'r': WriteError("commandline option -r is obsolete");
|
||||
break;
|
||||
|
||||
case 'l': forcedline = optarg;
|
||||
@ -377,7 +368,6 @@ int main(int argc, char *argv[])
|
||||
WriteError("Calling mbcico without node address not supported anymore");
|
||||
die(101);
|
||||
}
|
||||
// callist = callall();
|
||||
|
||||
for (tmpl = &callist; *tmpl; tmpl = &((*tmpl)->next)) {
|
||||
callno++;
|
||||
|
133
mbcico/portsel.c
133
mbcico/portsel.c
@ -1,6 +1,6 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $id$
|
||||
* $Id$
|
||||
* Purpose ...............: Fidonet mailer
|
||||
*
|
||||
*****************************************************************************
|
||||
@ -40,137 +40,6 @@
|
||||
extern char *name, *phone, *flags;
|
||||
|
||||
|
||||
/*
|
||||
* Tidy the portlist array
|
||||
*/
|
||||
void tidy_pplist(pp_list ** fdp)
|
||||
{
|
||||
pp_list *tmp, *old;
|
||||
int i;
|
||||
|
||||
Syslog('D', "tidy_pplist");
|
||||
|
||||
for (tmp = *fdp; tmp; tmp = old) {
|
||||
old = tmp->next;
|
||||
for (i = 0; i < MAXUFLAGS; i++)
|
||||
if (tmp->uflags[i])
|
||||
free(tmp->uflags[i]);
|
||||
free(tmp);
|
||||
}
|
||||
*fdp = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Add a port to the array
|
||||
*/
|
||||
void fill_pplist(pp_list **fdp, pp_list *new)
|
||||
{
|
||||
pp_list *tmp, *ta;
|
||||
int i;
|
||||
|
||||
tmp = (pp_list *)malloc(sizeof(pp_list));
|
||||
tmp->next = NULL;
|
||||
sprintf(tmp->tty, "%s", new->tty);
|
||||
tmp->mflags = new->mflags;
|
||||
tmp->dflags = new->dflags;
|
||||
tmp->iflags = new->iflags;
|
||||
moflags(new->mflags);
|
||||
diflags(new->dflags);
|
||||
ipflags(new->iflags);
|
||||
tmp->match = TRUE;
|
||||
for (i = 0; i < MAXUFLAGS; i++)
|
||||
tmp->uflags[i] = xstrcpy(new->uflags[i]);
|
||||
|
||||
if (*fdp == NULL)
|
||||
*fdp = tmp;
|
||||
else {
|
||||
for (ta = *fdp; ta; ta = ta->next)
|
||||
if (ta->next == NULL) {
|
||||
ta->next = (pp_list *)tmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Make a list of available ports to use for dialout. The ports
|
||||
* are selected on the available modem flags and the remote node
|
||||
* modem type.
|
||||
*/
|
||||
int make_portlist(node *nlent, pp_list **tmp)
|
||||
{
|
||||
char *temp, *p, *q;
|
||||
FILE *fp;
|
||||
int count = 0, j, ixflag, stdflag;
|
||||
pp_list new;
|
||||
|
||||
tidy_pplist(tmp);
|
||||
temp = calloc(PATH_MAX, sizeof(char));
|
||||
|
||||
sprintf(temp, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT"));
|
||||
if ((fp = fopen(temp, "r")) == NULL) {
|
||||
WriteError("$Can't open %s", temp);
|
||||
free(temp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Syslog('d', "Building portlist...");
|
||||
fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, fp);
|
||||
|
||||
while (fread(&ttyinfo, ttyinfohdr.recsize, 1, fp) == 1) {
|
||||
|
||||
if (((ttyinfo.type == POTS) || (ttyinfo.type == ISDN)) && (ttyinfo.available) && (ttyinfo.callout)) {
|
||||
memset(&new, 0, sizeof(new));
|
||||
sprintf(new.tty, "%s", ttyinfo.tty);
|
||||
stdflag = TRUE;
|
||||
ixflag = 0;
|
||||
q = xstrcpy(ttyinfo.flags);
|
||||
for (p = q; p; p = q) {
|
||||
if ((q = strchr(p, ',')))
|
||||
*q++ = '\0';
|
||||
if ((strncasecmp(p, "U", 1) == 0) && (strlen(p) == 1)) {
|
||||
stdflag = FALSE;
|
||||
} else {
|
||||
for (j = 0; fkey[j].key; j++)
|
||||
if (strcasecmp(p, fkey[j].key) == 0)
|
||||
new.mflags |= fkey[j].flag;
|
||||
for (j = 0; dkey[j].key; j++)
|
||||
if (strcasecmp(p, dkey[j].key) == 0)
|
||||
new.dflags |= dkey[j].flag;
|
||||
if (!stdflag) {
|
||||
if (ixflag < MAXUFLAGS) {
|
||||
new.uflags[ixflag++] = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Syslog('d', "flags: nodelist port %s", new.tty);
|
||||
Syslog('d', "modem %08lx %08lx", nlent->mflags, new.mflags);
|
||||
Syslog('d', "ISDN %08lx %08lx", nlent->dflags, new.dflags);
|
||||
|
||||
if ((nlent->mflags & new.mflags) || (nlent->dflags & new.dflags)) {
|
||||
fill_pplist(tmp, &new);
|
||||
count++;
|
||||
Syslog('d', "make_portlist add %s", ttyinfo.tty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
free(temp);
|
||||
|
||||
/* FIXME: sort ports on priority and remove ports with low speed. */
|
||||
|
||||
Syslog('d', "make_portlist %d ports", count);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int load_port(char *tty)
|
||||
{
|
||||
char *temp;
|
||||
|
@ -1,24 +1,11 @@
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _PORTSEL_H
|
||||
#define _PORTSEL_H
|
||||
|
||||
|
||||
typedef struct _pp_list {
|
||||
struct _pp_list *next;
|
||||
char tty[7]; /* tty name of the port */
|
||||
unsigned long mflags; /* Analogue Modem flags */
|
||||
unsigned long dflags; /* ISDN flags */
|
||||
unsigned long iflags; /* TCP-IP flags */
|
||||
char *uflags[MAXUFLAGS]; /* User flags */
|
||||
int match; /* Does port match */
|
||||
} pp_list;
|
||||
|
||||
|
||||
void tidy_pplist(pp_list **);
|
||||
void fill_pplist(pp_list **, pp_list *);
|
||||
int make_portlist(node *, pp_list **);
|
||||
int load_port(char *);
|
||||
int load_modem(char *);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "../lib/common.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "../lib/dbnode.h"
|
||||
#include "portsel.h"
|
||||
#include "session.h"
|
||||
#include "config.h"
|
||||
|
||||
|
Reference in New Issue
Block a user