2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2001-12-23 14:15:58 +00:00
|
|
|
* $Id$
|
|
|
|
* Purpose ...............: mbtask - Scan mail outbound status
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
*****************************************************************************
|
2007-09-02 11:01:26 +00:00
|
|
|
* Copyright (C) 1997-2007
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 13:20:57 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 17:22:00 +00:00
|
|
|
#include "../lib/mbselib.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "taskutil.h"
|
2001-12-29 12:59:40 +00:00
|
|
|
#include "taskstat.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "scanout.h"
|
2002-12-28 17:29:06 +00:00
|
|
|
#include "../lib/nodelist.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "callstat.h"
|
2002-03-03 20:40:03 +00:00
|
|
|
#include "ports.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
#include "outstat.h"
|
|
|
|
|
|
|
|
|
|
|
|
extern int do_quiet;
|
2001-12-29 12:59:40 +00:00
|
|
|
extern int internet; /* Internet status */
|
|
|
|
extern struct sysconfig CFG; /* Main configuration */
|
|
|
|
extern struct taskrec TCFG; /* Task configuration */
|
2004-01-14 20:51:22 +00:00
|
|
|
extern struct _fidonet fidonet; /* Fidonet records */
|
2001-12-29 12:59:40 +00:00
|
|
|
int nxt_hour, nxt_min; /* Time of next event */
|
|
|
|
int inet_calls; /* Internet calls to make */
|
|
|
|
int isdn_calls; /* ISDN calls to make */
|
|
|
|
int pots_calls; /* POTS calls to make */
|
|
|
|
_alist_l *alist = NULL; /* Nodes to call list */
|
2002-02-02 15:15:34 +00:00
|
|
|
extern int s_do_inet; /* Internet wanted */
|
2002-02-24 17:17:58 +00:00
|
|
|
extern int pots_lines; /* POTS lines available */
|
|
|
|
extern int isdn_lines; /* ISDN lines available */
|
2002-03-03 20:40:03 +00:00
|
|
|
extern pp_list *pl; /* Available ports */
|
2003-08-03 15:11:33 +00:00
|
|
|
extern char waitmsg[]; /* Waiting message */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2002-02-21 21:45:08 +00:00
|
|
|
/*
|
|
|
|
* Load noderecord if the node is in our setup.
|
|
|
|
*/
|
|
|
|
int load_node(fidoaddr);
|
|
|
|
int load_node(fidoaddr n)
|
|
|
|
{
|
|
|
|
char *temp;
|
|
|
|
FILE *fp;
|
2002-02-23 16:00:53 +00:00
|
|
|
int i, j = 0;
|
2002-02-21 21:45:08 +00:00
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/nodes.data", getenv("MBSE_ROOT"));
|
2002-02-21 21:45:08 +00:00
|
|
|
if ((fp = fopen(temp, "r")) == NULL) {
|
|
|
|
free(temp);
|
|
|
|
memset(&nodes, 0, sizeof(nodes));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2005-09-11 13:07:42 +00:00
|
|
|
free(temp);
|
|
|
|
|
2002-02-21 21:45:08 +00:00
|
|
|
fread(&nodeshdr, sizeof(nodeshdr), 1, fp);
|
|
|
|
while (fread(&nodes, nodeshdr.recsize, 1, fp) == 1) {
|
|
|
|
fseek(fp, nodeshdr.filegrp + nodeshdr.mailgrp, SEEK_CUR);
|
2002-02-23 16:00:53 +00:00
|
|
|
j++;
|
2002-02-21 21:45:08 +00:00
|
|
|
for (i = 0; i < 20; i++) {
|
2002-02-23 16:14:26 +00:00
|
|
|
if ((n.zone == nodes.Aka[i].zone) && (n.net == nodes.Aka[i].net) &&
|
|
|
|
(n.node == nodes.Aka[i].node) && (n.point == nodes.Aka[i].point)) {
|
2002-02-21 21:45:08 +00:00
|
|
|
fclose(fp);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
memset(&nodes, 0, sizeof(nodes));
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
void size_str_r(int, char *);
|
|
|
|
void size_str_r(int size, char *fmt)
|
2002-02-23 16:00:53 +00:00
|
|
|
{
|
|
|
|
if (size > 1048575) {
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(fmt, 25, "%dK", size / 1024);
|
2002-02-23 16:00:53 +00:00
|
|
|
} else {
|
2005-10-11 20:49:41 +00:00
|
|
|
snprintf(fmt, 25, "%d ", size);
|
2002-02-23 16:00:53 +00:00
|
|
|
}
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2002-02-23 16:00:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-12-29 12:59:40 +00:00
|
|
|
void set_next(int, int);
|
|
|
|
void set_next(int hour, int min)
|
|
|
|
{
|
|
|
|
time_t now;
|
2004-12-29 12:39:47 +00:00
|
|
|
struct tm etm;
|
2001-12-29 12:59:40 +00:00
|
|
|
int uhour, umin;
|
|
|
|
|
|
|
|
now = time(NULL);
|
2004-12-29 12:39:47 +00:00
|
|
|
gmtime_r(&now, &etm);
|
|
|
|
uhour = etm.tm_hour; /* For some reason, these intermediate integers are needed */
|
|
|
|
umin = etm.tm_min;
|
2001-12-29 12:59:40 +00:00
|
|
|
|
|
|
|
if ((hour > uhour) || ((hour == uhour) && (min > umin))) {
|
|
|
|
if (hour < nxt_hour) {
|
|
|
|
nxt_hour = hour;
|
|
|
|
nxt_min = min;
|
|
|
|
} else if ((hour == nxt_hour) && (min < nxt_min)) {
|
|
|
|
nxt_hour = hour;
|
|
|
|
nxt_min = min;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *callstatus(int status)
|
|
|
|
{
|
|
|
|
switch (status) {
|
2002-12-05 15:30:35 +00:00
|
|
|
case MBERR_OK: return (char *)"Ok ";
|
|
|
|
case MBERR_TTYIO_ERROR: return (char *)"tty err";
|
|
|
|
case MBERR_NO_CONNECTION: return (char *)"No conn";
|
|
|
|
case MBERR_MODEM_ERROR: return (char *)"Mdm err";
|
|
|
|
case MBERR_NODE_LOCKED: return (char *)"Locked ";
|
|
|
|
case MBERR_UNKNOWN_SESSION: return (char *)"unknown";
|
|
|
|
case MBERR_NODE_NOT_IN_LIST: return (char *)"Unlist ";
|
|
|
|
case MBERR_NODE_MAY_NOT_CALL: return (char *)"Forbid ";
|
|
|
|
case MBERR_FTRANSFER: return (char *)"Transf.";
|
|
|
|
case MBERR_NO_PORT_AVAILABLE: return (char *)"No tty ";
|
|
|
|
case MBERR_NOT_ZMH: return (char *)"No ZMH ";
|
|
|
|
case MBERR_SESSION_ERROR: return (char *)"Badsess";
|
2002-12-08 11:22:28 +00:00
|
|
|
case MBERR_NO_IP_ADDRESS: return (char *)"No IP ";
|
2002-12-28 17:29:06 +00:00
|
|
|
default: Syslog('-', "callstatus(%d), unknown", status);
|
2002-12-05 15:30:35 +00:00
|
|
|
return (char *)"ERROR ";
|
2001-12-29 12:59:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *callmode(int mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
2001-12-29 21:57:59 +00:00
|
|
|
case CM_NONE: return (char *)"None ";
|
|
|
|
case CM_INET: return (char *)"Inet ";
|
|
|
|
case CM_ISDN: return (char *)"ISDN ";
|
|
|
|
case CM_POTS: return (char *)"POTS ";
|
|
|
|
case MBFIDO: return (char *)"mbfido ";
|
|
|
|
case MBINDEX: return (char *)"mbindex";
|
|
|
|
case MBFILE: return (char *)"mbfile ";
|
|
|
|
case MBINIT: return (char *)"mbinit ";
|
|
|
|
default: return (char *)"None ";
|
2001-12-29 12:59:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
2004-01-14 20:51:22 +00:00
|
|
|
/*
|
|
|
|
* Scan one directory filebox
|
|
|
|
*/
|
|
|
|
void checkdir(char *boxpath, faddr *fa, char flavor)
|
|
|
|
{
|
2006-01-30 22:27:02 +00:00
|
|
|
char *temp, *buf;
|
2004-01-14 20:51:22 +00:00
|
|
|
DIR *dp = NULL;
|
|
|
|
struct dirent *de;
|
|
|
|
struct stat sb;
|
|
|
|
struct passwd *pw;
|
|
|
|
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2006-01-30 22:27:02 +00:00
|
|
|
buf = calloc(PATH_MAX, sizeof(char));
|
2004-01-14 20:51:22 +00:00
|
|
|
pw = getpwnam((char *)"mbse");
|
2006-01-30 22:27:02 +00:00
|
|
|
ascfnode_r(fa, 0xff, buf);
|
|
|
|
Syslog('o', "check filebox %s (%s) flavor %c", boxpath, buf, flavor);
|
|
|
|
free(buf);
|
2004-01-14 20:51:22 +00:00
|
|
|
|
|
|
|
if ((dp = opendir(boxpath)) != NULL) {
|
|
|
|
while ((de = readdir(dp))) {
|
|
|
|
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/%s", boxpath, de->d_name);
|
2004-01-14 20:51:22 +00:00
|
|
|
if (stat(temp, &sb) == 0) {
|
|
|
|
if (S_ISREG(sb.st_mode)) {
|
|
|
|
if (pw->pw_uid == sb.st_uid) {
|
|
|
|
/*
|
|
|
|
* We own the file
|
|
|
|
*/
|
|
|
|
if ((sb.st_mode & S_IRUSR) && (sb.st_mode & S_IWUSR)) {
|
|
|
|
each(fa, flavor, OUT_FIL, temp);
|
|
|
|
} else {
|
|
|
|
Syslog('+', "No R/W permission on %s", temp);
|
|
|
|
}
|
|
|
|
} else if (pw->pw_gid == sb.st_gid) {
|
|
|
|
/*
|
|
|
|
* We own the file group
|
|
|
|
*/
|
|
|
|
if ((sb.st_mode & S_IRGRP) && (sb.st_mode & S_IWGRP)) {
|
|
|
|
each(fa, flavor, OUT_FIL, temp);
|
|
|
|
} else {
|
|
|
|
Syslog('+', "No R/W permission on %s", temp);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* No owner of file
|
|
|
|
*/
|
|
|
|
if ((sb.st_mode & S_IROTH) && (sb.st_mode & S_IWOTH)) {
|
|
|
|
each(fa, flavor, OUT_FIL, temp);
|
|
|
|
} else {
|
|
|
|
Syslog('+', "No R/W permission on %s", temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Syslog('+', "Not a regular file: %s", temp);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Syslog('?', "Can't stat %s", temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dp);
|
|
|
|
}
|
|
|
|
free(temp);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
/*
|
2006-05-22 12:09:15 +00:00
|
|
|
* Scan outbound, the call status is set in three counters: internet, ISDN and POTS (analogue modems).
|
2002-02-24 12:56:14 +00:00
|
|
|
* For all systems the CM and Txx flags are checked and for official
|
2006-05-22 12:09:15 +00:00
|
|
|
* FidoNet nodes the Zone Mail Hour wich belongs to the destination zone.
|
|
|
|
* All nodes are qualified if there is a way to call them or not on this moment.
|
2002-02-24 12:56:14 +00:00
|
|
|
* The method how to call a node is decided as well.
|
2006-05-22 12:09:15 +00:00
|
|
|
*
|
|
|
|
* On success, return 0.
|
2002-02-24 12:56:14 +00:00
|
|
|
*/
|
2001-08-17 05:46:24 +00:00
|
|
|
int outstat()
|
|
|
|
{
|
2002-02-24 12:56:14 +00:00
|
|
|
int rc, first = TRUE, T_window, iszmh = FALSE;
|
|
|
|
struct _alist *tmp, *old;
|
2007-09-02 11:01:26 +00:00
|
|
|
char digit[6], flstr[15], *temp, as[6], be[6], utc[6], flavor, *temp2, *fmt, *buf;
|
2002-02-24 12:56:14 +00:00
|
|
|
time_t now;
|
2004-12-29 12:39:47 +00:00
|
|
|
struct tm tm;
|
2002-02-24 12:56:14 +00:00
|
|
|
int uhour, umin, thour, tmin;
|
2002-03-03 20:40:03 +00:00
|
|
|
pp_list *tpl;
|
2002-06-24 20:34:07 +00:00
|
|
|
faddr *fa;
|
|
|
|
FILE *fp;
|
|
|
|
DIR *dp = NULL;
|
|
|
|
struct dirent *de;
|
|
|
|
struct stat sb;
|
2007-04-30 20:20:33 +00:00
|
|
|
unsigned int ibnmask = 0, ifcmask = 0, itnmask = 0, outsize = 0;
|
2002-12-30 22:13:33 +00:00
|
|
|
nodelist_modem **tmpm;
|
|
|
|
|
|
|
|
for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) {
|
|
|
|
if (strcmp((*tmpm)->name, "IBN") == 0)
|
|
|
|
ibnmask = (*tmpm)->mask;
|
|
|
|
if (strcmp((*tmpm)->name, "IFC") == 0)
|
|
|
|
ifcmask = (*tmpm)->mask;
|
2003-11-22 21:42:44 +00:00
|
|
|
if (strcmp((*tmpm)->name, "ITN") == 0)
|
|
|
|
itnmask = (*tmpm)->mask;
|
2002-12-30 22:13:33 +00:00
|
|
|
}
|
2002-02-24 12:56:14 +00:00
|
|
|
now = time(NULL);
|
2006-01-30 22:27:02 +00:00
|
|
|
gmtime_r(&now, &tm); // UTC time
|
2004-12-29 12:39:47 +00:00
|
|
|
uhour = tm.tm_hour;
|
|
|
|
umin = tm.tm_min;
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(utc, 6, "%02d:%02d", uhour, umin);
|
2002-12-28 17:29:06 +00:00
|
|
|
Syslog('+', "Scanning outbound at %s UTC.", utc);
|
2002-02-24 12:56:14 +00:00
|
|
|
nxt_hour = 24;
|
|
|
|
nxt_min = 0;
|
|
|
|
inet_calls = isdn_calls = pots_calls = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear current table
|
|
|
|
*/
|
|
|
|
for (tmp = alist; tmp; tmp = old) {
|
|
|
|
old = tmp->next;
|
|
|
|
free(tmp);
|
|
|
|
}
|
|
|
|
alist = NULL;
|
|
|
|
|
|
|
|
if ((rc = scanout(each))) {
|
2002-12-28 17:29:06 +00:00
|
|
|
Syslog('?', "Error scanning outbound, aborting");
|
2002-02-24 12:56:14 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
2002-06-24 20:34:07 +00:00
|
|
|
/*
|
|
|
|
* Check private outbound box for nodes in the setup.
|
|
|
|
*/
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/etc/nodes.data", getenv("MBSE_ROOT"));
|
2002-06-24 20:34:07 +00:00
|
|
|
if ((fp = fopen(temp, "r")) == NULL) {
|
2002-12-28 17:29:06 +00:00
|
|
|
Syslog('?', "Error open %s, aborting", temp);
|
2002-06-24 20:34:07 +00:00
|
|
|
free(temp);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
fread(&nodeshdr, sizeof(nodeshdr), 1, fp);
|
|
|
|
fseek(fp, 0, SEEK_SET);
|
|
|
|
fread(&nodeshdr, nodeshdr.hdrsize, 1, fp);
|
|
|
|
|
|
|
|
while ((fread(&nodes, nodeshdr.recsize, 1, fp)) == 1) {
|
|
|
|
if (strlen(nodes.OutBox)) {
|
|
|
|
if (nodes.Crash)
|
|
|
|
flavor = 'c';
|
|
|
|
else if (nodes.Hold)
|
|
|
|
flavor = 'h';
|
|
|
|
else
|
|
|
|
flavor = 'o';
|
|
|
|
|
|
|
|
fa = (faddr *)malloc(sizeof(faddr));
|
|
|
|
fa->name = NULL;
|
|
|
|
fa->domain = xstrcpy(nodes.Aka[0].domain);
|
|
|
|
fa->zone = nodes.Aka[0].zone;
|
|
|
|
fa->net = nodes.Aka[0].net;
|
|
|
|
fa->node = nodes.Aka[0].node;
|
|
|
|
fa->point = nodes.Aka[0].point;
|
|
|
|
|
2004-01-14 20:51:22 +00:00
|
|
|
checkdir(nodes.OutBox, fa, flavor);
|
2002-06-24 20:34:07 +00:00
|
|
|
if (fa->domain)
|
|
|
|
free(fa->domain);
|
|
|
|
free(fa);
|
|
|
|
}
|
|
|
|
fseek(fp, nodeshdr.filegrp + nodeshdr.mailgrp, SEEK_CUR);
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
2004-01-14 20:51:22 +00:00
|
|
|
/*
|
|
|
|
* Start checking T-Mail fileboxes
|
|
|
|
*/
|
|
|
|
if (strlen(CFG.tmailshort) && (dp = opendir(CFG.tmailshort))) {
|
2004-01-22 20:10:59 +00:00
|
|
|
Syslog('o', "Checking T-Mail short box \"%s\"", CFG.tmailshort);
|
|
|
|
while ((de = readdir(dp))) {
|
|
|
|
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/%s", CFG.tmailshort, de->d_name);
|
2004-01-22 20:10:59 +00:00
|
|
|
if (stat(temp, &sb) == 0) {
|
|
|
|
Syslog('o' ,"checking \"%s\"", de->d_name);
|
|
|
|
if (S_ISDIR(sb.st_mode)) {
|
|
|
|
int i;
|
|
|
|
char b=0;
|
|
|
|
for (i=0; (i<8) && (!b); ++i) {
|
|
|
|
char c = tolower(de->d_name[i]);
|
|
|
|
if ( (c<'0') || (c>'v') || ((c>'9') && (c<'a')) ) b=1;
|
|
|
|
}
|
|
|
|
if (de->d_name[8]!='.') b=1;
|
|
|
|
for (i=9; (i<11) && (!b); ++i) {
|
|
|
|
char c = tolower(de->d_name[i]);
|
|
|
|
if ( (c<'0') || (c>'v') || ((c>'9') && (c<'a')) ) b=1;
|
|
|
|
}
|
|
|
|
if (b) continue;
|
|
|
|
if (de->d_name[11]==0) flavor='o';
|
|
|
|
else if ((tolower(de->d_name[11])=='h') && (de->d_name[12]==0)) flavor='h';
|
|
|
|
else continue;
|
|
|
|
fa = (faddr*)malloc(sizeof(faddr));
|
|
|
|
fa->name = NULL;
|
|
|
|
fa->domain = NULL;
|
|
|
|
memset(&digit, 0, sizeof(digit));
|
|
|
|
digit[0] = de->d_name[0];
|
|
|
|
digit[1] = de->d_name[1];
|
|
|
|
fa->zone = strtol(digit, NULL, 32);
|
|
|
|
memset(&digit, 0, sizeof(digit));
|
|
|
|
digit[0] = de->d_name[2];
|
|
|
|
digit[1] = de->d_name[3];
|
|
|
|
digit[2] = de->d_name[4];
|
|
|
|
fa->net = strtol(digit, NULL, 32);
|
|
|
|
memset(&digit, 0, sizeof(digit));
|
|
|
|
digit[0] = de->d_name[5];
|
|
|
|
digit[1] = de->d_name[6];
|
|
|
|
digit[2] = de->d_name[7];
|
|
|
|
fa->node = strtol(digit, NULL, 32);
|
|
|
|
memset(&digit, 0, sizeof(digit));
|
|
|
|
digit[0] = de->d_name[9];
|
|
|
|
digit[1] = de->d_name[10];
|
|
|
|
fa->point = strtol(digit, NULL, 32);
|
|
|
|
if (SearchFidonet(fa->zone)) {
|
|
|
|
fa->domain = xstrcpy(fidonet.domain);
|
2004-04-29 19:25:14 +00:00
|
|
|
checkdir(temp, fa, flavor);
|
2004-01-22 20:10:59 +00:00
|
|
|
}
|
2004-01-14 20:51:22 +00:00
|
|
|
if (fa->domain)
|
|
|
|
free(fa->domain);
|
|
|
|
free(fa);
|
2004-01-22 20:10:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dp);
|
2004-01-14 20:51:22 +00:00
|
|
|
}
|
|
|
|
if (strlen(CFG.tmaillong) && (dp = opendir(CFG.tmaillong))) {
|
2004-01-22 20:10:59 +00:00
|
|
|
temp2 = calloc(PATH_MAX, sizeof(char));
|
|
|
|
Syslog('o', "Checking T-Mail long box \"%s\"", CFG.tmaillong);
|
|
|
|
while ((de = readdir(dp))) {
|
|
|
|
if (strcmp(de->d_name, ".") && strcmp(de->d_name, "..")) {
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(temp, PATH_MAX, "%s/%s", CFG.tmaillong, de->d_name);
|
2004-01-22 20:10:59 +00:00
|
|
|
if (stat(temp, &sb) == 0) {
|
|
|
|
Syslog('o' ,"checking \"%s\"", de->d_name);
|
|
|
|
if (S_ISDIR(sb.st_mode)) {
|
|
|
|
char c, d;
|
|
|
|
int n;
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(temp2, PATH_MAX, "%s", de->d_name);
|
2004-01-22 20:10:59 +00:00
|
|
|
fa = (faddr*)malloc(sizeof(faddr));
|
|
|
|
fa->name = NULL;
|
|
|
|
fa->domain = NULL;
|
|
|
|
n = sscanf(temp2, "%u.%u.%u.%u.%c%c", &(fa->zone), &(fa->net), &(fa->node), &(fa->point), &c, &d);
|
|
|
|
if ((n==4) || ((n==5) && (tolower(c)=='h'))) {
|
|
|
|
if (SearchFidonet(fa->zone)) {
|
|
|
|
fa->domain = xstrcpy(fidonet.domain);
|
2004-04-29 19:25:14 +00:00
|
|
|
if (n==4)
|
|
|
|
flavor = 'o';
|
|
|
|
else
|
|
|
|
flavor = 'h';
|
|
|
|
checkdir(temp, fa, flavor);
|
2004-01-22 20:10:59 +00:00
|
|
|
}
|
|
|
|
}
|
2004-01-14 20:51:22 +00:00
|
|
|
if (fa->domain)
|
|
|
|
free(fa->domain);
|
|
|
|
free(fa);
|
2004-01-22 20:10:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
closedir(dp);
|
|
|
|
free(temp2);
|
2004-01-14 20:51:22 +00:00
|
|
|
}
|
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
/*
|
|
|
|
* During processing the outbound list, determine when the next event will occur,
|
|
|
|
* ie. the time when the callout status of a node changes because of starting a
|
|
|
|
* ZMH, or changeing the time window for Txx flags.
|
|
|
|
*/
|
|
|
|
for (tmp = alist; tmp; tmp = tmp->next) {
|
|
|
|
if (first) {
|
2002-12-28 17:29:06 +00:00
|
|
|
Syslog('+', "Flavor Out Size Online Modem ISDN TCP/IP Calls Status Mode Address");
|
2002-02-24 12:56:14 +00:00
|
|
|
first = FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
rc = load_node(tmp->addr);
|
|
|
|
|
2001-12-29 12:59:40 +00:00
|
|
|
/*
|
2002-02-24 12:56:14 +00:00
|
|
|
* Zone Mail Hours, only use Fidonet Hours.
|
|
|
|
* Other nets use your default ZMH.
|
2001-12-29 12:59:40 +00:00
|
|
|
*/
|
2002-02-24 12:56:14 +00:00
|
|
|
T_window = iszmh = FALSE;
|
|
|
|
switch (tmp->addr.zone) {
|
|
|
|
case 1: if (uhour == 9)
|
|
|
|
iszmh = TRUE;
|
|
|
|
set_next(9, 0);
|
|
|
|
set_next(10, 0);
|
|
|
|
break;
|
|
|
|
case 2: if (((uhour == 2) && (umin >= 30)) || ((uhour == 3) && (umin < 30)))
|
|
|
|
iszmh = TRUE;
|
|
|
|
set_next(2, 30);
|
|
|
|
set_next(3, 30);
|
|
|
|
break;
|
|
|
|
case 3: if (uhour == 18)
|
|
|
|
iszmh = TRUE;
|
|
|
|
set_next(18, 0);
|
|
|
|
set_next(19, 0);
|
|
|
|
break;
|
|
|
|
case 4: if (uhour == 8)
|
|
|
|
iszmh = TRUE;
|
|
|
|
set_next(8, 0);
|
|
|
|
set_next(9, 0);
|
|
|
|
break;
|
|
|
|
case 5: if (uhour == 1)
|
|
|
|
iszmh = TRUE;
|
|
|
|
set_next(1, 0);
|
|
|
|
set_next(2, 0);
|
|
|
|
break;
|
|
|
|
case 6: if (uhour == 20)
|
|
|
|
iszmh = TRUE;
|
|
|
|
set_next(20, 0);
|
|
|
|
set_next(21, 0);
|
|
|
|
break;
|
|
|
|
default: if (get_zmh())
|
|
|
|
iszmh = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2002-02-21 21:45:08 +00:00
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
if (tmp->t1 && tmp->t2) {
|
|
|
|
/*
|
|
|
|
* Txx flags, check callwindow
|
|
|
|
*/
|
|
|
|
thour = toupper(tmp->t1) - 'A';
|
|
|
|
if (isupper(tmp->t1))
|
|
|
|
tmin = 0;
|
|
|
|
else
|
|
|
|
tmin = 30;
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(as, 6, "%02d:%02d", thour, tmin);
|
2002-02-24 12:56:14 +00:00
|
|
|
set_next(thour, tmin);
|
|
|
|
thour = toupper(tmp->t2) - 'A';
|
|
|
|
if (isupper(tmp->t2))
|
|
|
|
tmin = 0;
|
|
|
|
else
|
|
|
|
tmin = 30;
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(be, 6, "%02d:%02d", thour, tmin);
|
2002-02-24 12:56:14 +00:00
|
|
|
set_next(thour, tmin);
|
|
|
|
if (strcmp(as, be) > 0) {
|
2001-12-29 12:59:40 +00:00
|
|
|
/*
|
2002-02-24 12:56:14 +00:00
|
|
|
* Time window is passing midnight
|
2001-12-29 12:59:40 +00:00
|
|
|
*/
|
2002-02-24 12:56:14 +00:00
|
|
|
if ((strcmp(utc, as) >= 0) || (strcmp(utc, be) < 0))
|
|
|
|
T_window = TRUE;
|
|
|
|
} else {
|
2001-12-30 15:04:11 +00:00
|
|
|
/*
|
2002-02-24 12:56:14 +00:00
|
|
|
* Time window is not passing midnight
|
2001-12-30 15:04:11 +00:00
|
|
|
*/
|
2002-02-24 12:56:14 +00:00
|
|
|
if ((strcmp(utc, as) >= 0) && (strcmp(utc, be) < 0))
|
|
|
|
T_window = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2007-09-16 12:58:53 +00:00
|
|
|
memset(&flstr, 0, sizeof(flstr));
|
2007-09-02 11:01:26 +00:00
|
|
|
strncpy(flstr, "...... .... ..", 14);
|
2002-02-24 12:56:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the node has internet and we have internet configured,
|
2004-06-06 19:21:27 +00:00
|
|
|
* check if we can send immediatly. Works for CM and ICM.
|
2002-02-24 12:56:14 +00:00
|
|
|
*/
|
2004-06-19 17:41:06 +00:00
|
|
|
if (TCFG.max_tcp && (tmp->can_ip && tmp->is_icm) &&
|
2002-02-24 12:56:14 +00:00
|
|
|
(((tmp->flavors) & F_IMM) || ((tmp->flavors) & F_CRASH) || ((tmp->flavors) & F_NORMAL)) &&
|
2003-11-22 21:42:44 +00:00
|
|
|
((tmp->ipflags & ibnmask) || (tmp->ipflags & ifcmask) || (tmp->ipflags & itnmask))) {
|
2002-02-24 12:56:14 +00:00
|
|
|
tmp->flavors |= F_CALL;
|
|
|
|
}
|
|
|
|
|
2004-06-06 19:21:27 +00:00
|
|
|
/*
|
|
|
|
* Immediate Mail check
|
|
|
|
*/
|
2002-02-24 12:56:14 +00:00
|
|
|
if ((tmp->flavors) & F_IMM) {
|
2004-07-12 20:00:52 +00:00
|
|
|
flstr[0]='D';
|
2002-02-24 12:56:14 +00:00
|
|
|
/*
|
|
|
|
* Immediate mail, send if node is CM or is in a Txx window or is in ZMH.
|
|
|
|
*/
|
2004-06-18 19:54:13 +00:00
|
|
|
if (tmp->is_cm || T_window || iszmh) {
|
2002-02-24 12:56:14 +00:00
|
|
|
tmp->flavors |= F_CALL;
|
|
|
|
}
|
2004-06-06 19:21:27 +00:00
|
|
|
/*
|
|
|
|
* Now check again for the ICM flag.
|
|
|
|
*/
|
2004-06-18 19:54:13 +00:00
|
|
|
if (tmp->is_icm && TCFG.max_tcp &&
|
2004-06-06 19:21:27 +00:00
|
|
|
((tmp->ipflags & ibnmask) || (tmp->ipflags & ifcmask) || (tmp->ipflags & itnmask))) {
|
|
|
|
tmp->flavors |= F_CALL;
|
|
|
|
}
|
2002-02-24 12:56:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ((tmp->flavors) & F_CRASH ) {
|
|
|
|
flstr[1]='C';
|
|
|
|
/*
|
|
|
|
* Crash mail, send if node is CM or is in a Txx window or is in ZMH.
|
|
|
|
*/
|
2004-06-18 19:54:13 +00:00
|
|
|
if (tmp->is_cm || T_window || iszmh) {
|
2002-02-24 12:56:14 +00:00
|
|
|
tmp->flavors |= F_CALL;
|
|
|
|
}
|
2004-06-06 19:21:27 +00:00
|
|
|
/*
|
|
|
|
* Now check again for the ICM flag.
|
|
|
|
*/
|
2004-06-18 19:54:13 +00:00
|
|
|
if (tmp->is_icm && TCFG.max_tcp &&
|
2004-06-06 19:21:27 +00:00
|
|
|
((tmp->ipflags & ibnmask) || (tmp->ipflags & ifcmask) || (tmp->ipflags & itnmask))) {
|
|
|
|
tmp->flavors |= F_CALL;
|
|
|
|
}
|
2002-02-24 12:56:14 +00:00
|
|
|
}
|
2001-12-29 12:59:40 +00:00
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
if ((tmp->flavors) & F_NORMAL)
|
|
|
|
flstr[2]='N';
|
|
|
|
if ((tmp->flavors) & F_HOLD )
|
|
|
|
flstr[3]='H';
|
|
|
|
if ((tmp->flavors) & F_FREQ )
|
|
|
|
flstr[4]='R';
|
|
|
|
if ((tmp->flavors) & F_POLL ) {
|
|
|
|
flstr[5]='P';
|
|
|
|
tmp->flavors |= F_CALL;
|
|
|
|
}
|
2002-06-24 20:34:07 +00:00
|
|
|
|
2003-01-22 18:52:27 +00:00
|
|
|
if ((tmp->flavors) & F_ISFIL ) {
|
2002-06-24 20:34:07 +00:00
|
|
|
flstr[7]='A';
|
2003-01-22 18:52:27 +00:00
|
|
|
/*
|
|
|
|
* Arcmail and maybe file attaches, send during ZMH or if node has a Txx window.
|
|
|
|
*/
|
2004-08-13 14:05:18 +00:00
|
|
|
if ((iszmh || T_window) && !((tmp->flavors) & F_HOLD)) {
|
2003-01-22 18:52:27 +00:00
|
|
|
tmp->flavors |= F_CALL;
|
|
|
|
}
|
|
|
|
}
|
2004-06-06 19:21:27 +00:00
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
if ((tmp->flavors) & F_ISPKT ) {
|
2002-06-24 20:34:07 +00:00
|
|
|
flstr[8]='M';
|
2002-02-24 12:56:14 +00:00
|
|
|
/*
|
|
|
|
* Normal mail, send during ZMH or if node has a Txx window.
|
|
|
|
*/
|
2004-08-13 14:05:18 +00:00
|
|
|
if ((iszmh || T_window) && !((tmp->flavors) & F_HOLD)) {
|
2002-02-24 12:56:14 +00:00
|
|
|
tmp->flavors |= F_CALL;
|
|
|
|
}
|
|
|
|
}
|
2004-08-13 14:05:18 +00:00
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
if ((tmp->flavors) & F_ISFLO )
|
2002-06-24 20:34:07 +00:00
|
|
|
flstr[9]='F';
|
2002-02-24 12:56:14 +00:00
|
|
|
|
|
|
|
if (tmp->cst.tryno >= 30) {
|
|
|
|
/*
|
|
|
|
* Node is undialable, clear callflag
|
|
|
|
*/
|
|
|
|
tmp->flavors &= ~F_CALL;
|
|
|
|
}
|
|
|
|
if (tmp->t1)
|
2002-06-24 20:34:07 +00:00
|
|
|
flstr[12] = tmp->t1;
|
2002-02-24 12:56:14 +00:00
|
|
|
if (tmp->t2)
|
2002-06-24 20:34:07 +00:00
|
|
|
flstr[13] = tmp->t2;
|
2002-02-24 12:56:14 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If forbidden to call from setup, clear callflag.
|
|
|
|
*/
|
|
|
|
if (nodes.NoCall)
|
|
|
|
tmp->flavors &= ~F_CALL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we must call this node, figure out how to call this node.
|
|
|
|
*/
|
|
|
|
if ((tmp->flavors) & F_CALL) {
|
|
|
|
tmp->callmode = CM_NONE;
|
|
|
|
|
2003-11-22 21:42:44 +00:00
|
|
|
if (TCFG.max_tcp && ((tmp->ipflags & ibnmask) || (tmp->ipflags & ifcmask) || (tmp->ipflags & itnmask))) {
|
2002-02-24 12:56:14 +00:00
|
|
|
inet_calls++;
|
|
|
|
tmp->callmode = CM_INET;
|
|
|
|
}
|
|
|
|
|
2002-02-24 17:17:58 +00:00
|
|
|
if ((tmp->callmode == CM_NONE) && isdn_lines) {
|
2002-02-21 21:45:08 +00:00
|
|
|
/*
|
2002-03-03 20:40:03 +00:00
|
|
|
* If any matching port found, mark node ISDN
|
2002-02-21 21:45:08 +00:00
|
|
|
*/
|
2002-03-03 20:40:03 +00:00
|
|
|
for (tpl = pl; tpl; tpl = tpl->next) {
|
|
|
|
if (tmp->diflags & tpl->dflags) {
|
|
|
|
isdn_calls++;
|
|
|
|
tmp->callmode = CM_ISDN;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-02-24 12:56:14 +00:00
|
|
|
}
|
2002-02-21 21:45:08 +00:00
|
|
|
|
2002-02-24 17:17:58 +00:00
|
|
|
if ((tmp->callmode == CM_NONE) && pots_lines) {
|
2001-12-29 12:59:40 +00:00
|
|
|
/*
|
2002-03-03 20:40:03 +00:00
|
|
|
* If any matching ports found, mark node POTS
|
2001-12-29 12:59:40 +00:00
|
|
|
*/
|
2002-03-03 20:40:03 +00:00
|
|
|
for (tpl = pl; tpl; tpl = tpl->next) {
|
|
|
|
if (tmp->moflags & tpl->mflags) {
|
|
|
|
pots_calls++;
|
|
|
|
tmp->callmode = CM_POTS;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2002-02-24 12:56:14 +00:00
|
|
|
}
|
2002-02-24 17:17:58 +00:00
|
|
|
|
|
|
|
/*
|
2002-03-03 20:40:03 +00:00
|
|
|
* Here we are out of options, clear callflag.
|
2002-02-24 17:17:58 +00:00
|
|
|
*/
|
|
|
|
if (tmp->callmode == CM_NONE) {
|
2006-01-30 22:27:02 +00:00
|
|
|
buf = calloc(81, sizeof(char));
|
|
|
|
fido2str_r(tmp->addr, 0x0f, buf);
|
|
|
|
Syslog('!', "No method to call %s available", buf);
|
|
|
|
free(buf);
|
2002-03-03 20:40:03 +00:00
|
|
|
tmp->flavors &= ~F_CALL;
|
2002-02-24 17:17:58 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-07-08 19:40:22 +00:00
|
|
|
|
|
|
|
if ((tmp->flavors) & F_CALL)
|
|
|
|
flstr[10]='C';
|
|
|
|
else
|
|
|
|
/*
|
|
|
|
* Safety, clear callmode.
|
|
|
|
*/
|
|
|
|
tmp->callmode = CM_NONE;
|
2001-12-29 12:59:40 +00:00
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
/*
|
|
|
|
* Show callresult for this node.
|
|
|
|
*/
|
2007-04-30 20:20:33 +00:00
|
|
|
outsize += (unsigned int)tmp->size;
|
2006-01-30 22:27:02 +00:00
|
|
|
fmt = calloc(81, sizeof(char));
|
|
|
|
buf = calloc(81, sizeof(char));
|
|
|
|
size_str_r(tmp->size, fmt);
|
|
|
|
fido2str_r(tmp->addr, 0x0f, buf);
|
|
|
|
snprintf(temp, PATH_MAX, "%s %8s %08x %08x %08x %08x %5d %s %s %s", flstr, fmt,
|
2002-02-24 12:56:14 +00:00
|
|
|
(unsigned int)tmp->olflags, (unsigned int)tmp->moflags,
|
|
|
|
(unsigned int)tmp->diflags, (unsigned int)tmp->ipflags,
|
2006-01-30 22:27:02 +00:00
|
|
|
tmp->cst.tryno, callstatus(tmp->cst.trystat), callmode(tmp->callmode), buf);
|
2002-12-28 17:29:06 +00:00
|
|
|
Syslog('+', "%s", temp);
|
2006-01-30 22:27:02 +00:00
|
|
|
free(fmt);
|
|
|
|
free(buf);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
} /* All nodes scanned. */
|
|
|
|
|
|
|
|
if (nxt_hour == 24) {
|
2002-02-23 21:54:10 +00:00
|
|
|
/*
|
2002-02-24 12:56:14 +00:00
|
|
|
* 24:00 hours doesn't exist
|
2002-02-23 21:54:10 +00:00
|
|
|
*/
|
2002-02-24 12:56:14 +00:00
|
|
|
nxt_hour = 0;
|
|
|
|
nxt_min = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Always set/reset semafore do_inet if internet is needed.
|
|
|
|
*/
|
|
|
|
if (!IsSema((char *)"do_inet") && inet_calls) {
|
|
|
|
CreateSema((char *)"do_inet");
|
|
|
|
s_do_inet = TRUE;
|
2002-12-28 17:29:06 +00:00
|
|
|
Syslog('c', "Created semafore do_inet");
|
2002-02-24 12:56:14 +00:00
|
|
|
} else if (IsSema((char *)"do_inet") && !inet_calls) {
|
|
|
|
RemoveSema((char *)"do_inet");
|
|
|
|
s_do_inet = FALSE;
|
2002-12-28 17:29:06 +00:00
|
|
|
Syslog('c', "Removed semafore do_inet");
|
2002-02-24 12:56:14 +00:00
|
|
|
}
|
2002-02-23 21:54:10 +00:00
|
|
|
|
2007-04-30 20:20:33 +00:00
|
|
|
/*
|
|
|
|
* Update outbound size MIB
|
|
|
|
*/
|
|
|
|
mib_set_outsize(outsize);
|
|
|
|
|
2002-02-24 12:56:14 +00:00
|
|
|
/*
|
|
|
|
* Log results
|
|
|
|
*/
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(waitmsg, 81, "Next event at %02d:%02d UTC", nxt_hour, nxt_min);
|
2002-12-28 17:29:06 +00:00
|
|
|
Syslog('+', "Systems to call: Inet=%d, ISDN=%d, POTS=%d, Next event at %02d:%02d UTC",
|
2002-02-24 12:56:14 +00:00
|
|
|
inet_calls, isdn_calls, pots_calls, nxt_hour, nxt_min);
|
2002-06-24 20:34:07 +00:00
|
|
|
free(temp);
|
2002-02-24 12:56:14 +00:00
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int each(faddr *addr, char flavor, int isflo, char *fname)
|
|
|
|
{
|
2003-02-08 14:21:33 +00:00
|
|
|
struct _alist **tmp;
|
|
|
|
struct stat st;
|
|
|
|
FILE *fp;
|
2006-01-30 22:27:02 +00:00
|
|
|
char buf[256], *p, *buf2;
|
2003-02-08 14:21:33 +00:00
|
|
|
node *nlent;
|
|
|
|
callstat *cst;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-08 14:21:33 +00:00
|
|
|
if ((isflo != OUT_PKT) && (isflo != OUT_FLO) && (isflo != OUT_REQ) && (isflo != OUT_POL) && (isflo != OUT_FIL))
|
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-08 14:21:33 +00:00
|
|
|
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) {
|
|
|
|
nlent = getnlent(addr);
|
|
|
|
*tmp = (struct _alist *)malloc(sizeof(struct _alist));
|
|
|
|
(*tmp)->next = NULL;
|
|
|
|
(*tmp)->addr.zone = addr->zone;
|
|
|
|
(*tmp)->addr.net = addr->net;
|
|
|
|
(*tmp)->addr.node = addr->node;
|
|
|
|
(*tmp)->addr.point = addr->point;
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf((*tmp)->addr.domain, 13, "%s", addr->domain);
|
2003-02-08 14:21:33 +00:00
|
|
|
if (nlent->addr.domain)
|
|
|
|
free(nlent->addr.domain);
|
2003-12-06 16:35:33 +00:00
|
|
|
if (nlent->url)
|
|
|
|
free(nlent->url);
|
|
|
|
nlent->url = NULL;
|
2003-02-08 14:21:33 +00:00
|
|
|
(*tmp)->flavors = 0;
|
|
|
|
if (nlent->pflag != NL_DUMMY) {
|
|
|
|
(*tmp)->olflags = nlent->oflags;
|
|
|
|
(*tmp)->moflags = nlent->mflags;
|
|
|
|
(*tmp)->diflags = nlent->dflags;
|
|
|
|
(*tmp)->ipflags = nlent->iflags;
|
|
|
|
(*tmp)->t1 = nlent->t1;
|
|
|
|
(*tmp)->t2 = nlent->t2;
|
2004-06-18 19:54:13 +00:00
|
|
|
(*tmp)->can_pots = nlent->can_pots;
|
|
|
|
(*tmp)->can_ip = nlent->can_ip;
|
|
|
|
(*tmp)->is_cm = nlent->is_cm;
|
|
|
|
(*tmp)->is_icm = nlent->is_icm;
|
2003-02-08 14:21:33 +00:00
|
|
|
} else {
|
|
|
|
(*tmp)->olflags = 0L;
|
|
|
|
(*tmp)->moflags = 0L;
|
|
|
|
(*tmp)->diflags = 0L;
|
|
|
|
(*tmp)->ipflags = 0L;
|
|
|
|
(*tmp)->t1 = '\0';
|
|
|
|
(*tmp)->t2 = '\0';
|
2004-06-18 19:54:13 +00:00
|
|
|
(*tmp)->can_pots = FALSE;
|
|
|
|
(*tmp)->can_ip = FALSE;
|
|
|
|
(*tmp)->is_cm = FALSE;
|
|
|
|
(*tmp)->is_icm = FALSE;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-08 14:21:33 +00:00
|
|
|
(*tmp)->time = time(NULL);
|
|
|
|
(*tmp)->size = 0L;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
cst = malloc(sizeof(callstat));
|
|
|
|
getstatus_r(addr, cst);
|
2003-02-08 14:21:33 +00:00
|
|
|
(*tmp)->cst.trytime = cst->trytime;
|
|
|
|
(*tmp)->cst.tryno = cst->tryno;
|
|
|
|
(*tmp)->cst.trystat = cst->trystat;
|
2006-01-30 22:27:02 +00:00
|
|
|
free(cst);
|
2003-02-08 14:21:33 +00:00
|
|
|
|
|
|
|
if ((isflo == OUT_FLO) || (isflo == OUT_PKT) || (isflo == OUT_FIL))
|
|
|
|
switch (flavor) {
|
|
|
|
case '?': break;
|
2004-07-12 20:00:52 +00:00
|
|
|
case 'd': (*tmp)->flavors |= F_IMM; break;
|
2003-02-08 14:21:33 +00:00
|
|
|
case 'o': (*tmp)->flavors |= F_NORMAL; break;
|
|
|
|
case 'c': (*tmp)->flavors |= F_CRASH; break;
|
|
|
|
case 'h': (*tmp)->flavors |= F_HOLD; break;
|
|
|
|
default: Syslog('?', "Unknown flavor: '%c'\n",flavor); break;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-08 14:21:33 +00:00
|
|
|
if (stat(fname,&st) != 0) {
|
|
|
|
Syslog('?', "$Can't stat %s", fname);
|
|
|
|
st.st_size = 0L;
|
|
|
|
st.st_mtime = time(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the oldest time
|
|
|
|
*/
|
|
|
|
if (st.st_mtime < (*tmp)->time)
|
|
|
|
(*tmp)->time = st.st_mtime;
|
|
|
|
|
|
|
|
if (isflo == OUT_FLO) {
|
|
|
|
(*tmp)->flavors |= F_ISFLO;
|
|
|
|
if ((fp = fopen(fname,"r"))) {
|
|
|
|
while (fgets(buf, sizeof(buf) - 1, fp)) {
|
|
|
|
if (*(p = buf + strlen(buf) - 1) == '\n')
|
|
|
|
*p-- = '\0';
|
|
|
|
while (isspace(*p))
|
|
|
|
*p-- = '\0';
|
|
|
|
for (p = buf; *p; p++)
|
|
|
|
if (*p == '\\')
|
|
|
|
*p='/';
|
|
|
|
for (p = buf; *p && isspace(*p); p++);
|
|
|
|
if (*p == '~')
|
|
|
|
continue;
|
|
|
|
if ((*p == '#') || (*p == '-') || (*p == '^') || (*p == '@'))
|
|
|
|
p++;
|
|
|
|
if (stat(p, &st) != 0) {
|
|
|
|
if (strlen(CFG.dospath)) {
|
2006-01-30 22:27:02 +00:00
|
|
|
buf2 = calloc(PATH_MAX, sizeof(char));
|
|
|
|
Dos2Unix_r(p, buf2);
|
|
|
|
if (stat(buf2, &st) != 0) {
|
2003-02-08 14:21:33 +00:00
|
|
|
/*
|
|
|
|
* Fileattach dissapeared, maybe
|
|
|
|
* the node doesn't poll enough and
|
|
|
|
* is losing mail or files.
|
|
|
|
*/
|
|
|
|
st.st_size = 0L;
|
|
|
|
st.st_mtime = time(NULL);
|
|
|
|
}
|
2006-01-30 22:27:02 +00:00
|
|
|
free(buf2);
|
2003-02-08 14:21:33 +00:00
|
|
|
} else {
|
|
|
|
if (stat(p, &st) != 0) {
|
|
|
|
st.st_size = 0L;
|
|
|
|
st.st_mtime = time(NULL);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-08 14:21:33 +00:00
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-08 14:21:33 +00:00
|
|
|
if ((p = strrchr(fname,'/')))
|
|
|
|
p++;
|
|
|
|
else
|
|
|
|
p = fname;
|
|
|
|
if ((strlen(p) == 12) && (strspn(p,"0123456789abcdefABCDEF") == 8) && (p[8] == '.')) {
|
|
|
|
if (st.st_mtime < (*tmp)->time)
|
|
|
|
(*tmp)->time = st.st_mtime;
|
|
|
|
}
|
2002-06-24 20:34:07 +00:00
|
|
|
(*tmp)->size += st.st_size;
|
2003-02-08 14:21:33 +00:00
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
} else
|
|
|
|
Syslog('?', "Can't open %s", fname);
|
|
|
|
|
|
|
|
} else if (isflo == OUT_PKT) {
|
|
|
|
(*tmp)->size += st.st_size;
|
|
|
|
(*tmp)->flavors |= F_ISPKT;
|
|
|
|
} else if (isflo == OUT_REQ) {
|
|
|
|
(*tmp)->flavors |= F_FREQ;
|
|
|
|
} else if (isflo == OUT_POL) {
|
|
|
|
(*tmp)->flavors |= F_POLL;
|
|
|
|
} else if (isflo == OUT_FIL) {
|
|
|
|
(*tmp)->size += st.st_size;
|
|
|
|
(*tmp)->flavors |= F_ISFIL;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-08 14:21:33 +00:00
|
|
|
return 0;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|