2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
2002-06-05 21:07:36 +00:00
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Read mailer last call status
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2006-01-30 22:27:02 +00:00
|
|
|
* Copyright (C) 1997-2006
|
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"
|
|
|
|
#include "callstat.h"
|
|
|
|
|
|
|
|
|
|
|
|
extern struct sysconfig CFG;
|
|
|
|
|
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
void stsname_r(faddr *, char *);
|
|
|
|
void stsname_r(faddr *addr, char *buf)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2003-02-08 14:21:33 +00:00
|
|
|
char *p, *domain=NULL, zpref[8];
|
|
|
|
int i;
|
|
|
|
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(buf, PATH_MAX, "%s", CFG.outbound);
|
2003-02-08 14:21:33 +00:00
|
|
|
|
|
|
|
if (CFG.addr4d) {
|
|
|
|
if ((addr->zone == 0) || (addr->zone == CFG.aka[0].zone))
|
|
|
|
zpref[0] = '\0';
|
|
|
|
else
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(zpref, 8, ".%03x", addr->zone);
|
2003-02-08 14:21:33 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* If we got a 5d address we use the given domain, if
|
|
|
|
* we got a 4d address, we look for a matching domain name.
|
|
|
|
*/
|
|
|
|
if (addr->domain)
|
|
|
|
domain = xstrcpy(addr->domain);
|
|
|
|
else
|
|
|
|
for (i = 0; i < 40; i++)
|
|
|
|
if (CFG.aka[i].zone == addr->zone) {
|
|
|
|
domain = xstrcpy(CFG.aka[i].domain);
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2003-02-08 14:21:33 +00:00
|
|
|
|
|
|
|
if ((domain != NULL) && (strlen(CFG.aka[0].domain) != 0) && (strcasecmp(domain,CFG.aka[0].domain) != 0)) {
|
|
|
|
if ((p = strrchr(buf,'/')))
|
|
|
|
p++;
|
|
|
|
else
|
|
|
|
p = buf;
|
|
|
|
strcpy(p, domain);
|
|
|
|
for (; *p; p++)
|
|
|
|
*p = tolower(*p);
|
|
|
|
for (i = 0; i < 40; i++)
|
|
|
|
if ((strlen(CFG.aka[i].domain)) && (strcasecmp(CFG.aka[i].domain, domain) == 0))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The default zone must be the first one in the
|
|
|
|
* setup, other zones get the hexadecimal zone
|
|
|
|
* number appended.
|
|
|
|
*/
|
|
|
|
if (CFG.aka[i].zone == addr->zone)
|
|
|
|
zpref[0] = '\0';
|
|
|
|
else
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(zpref, 8, ".%03x", addr->zone);
|
2003-02-08 14:21:33 +00:00
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* this is our primary domain
|
|
|
|
*/
|
|
|
|
if ((addr->zone == 0) || (addr->zone == CFG.aka[0].zone))
|
|
|
|
zpref[0]='\0';
|
|
|
|
else
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(zpref, 8, ".%03x",addr->zone);
|
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
|
|
|
p = buf + strlen(buf);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-08 14:21:33 +00:00
|
|
|
if (addr->point)
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(p, PATH_MAX - strlen(buf), "%s/%04x%04x.pnt/%08x.sts", zpref,addr->net,addr->node,addr->point);
|
2003-02-08 14:21:33 +00:00
|
|
|
else
|
2005-08-29 21:03:28 +00:00
|
|
|
snprintf(p, PATH_MAX - strlen(buf), "%s/%04x%04x.sts",zpref,addr->net,addr->node);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2003-02-08 14:21:33 +00:00
|
|
|
if (domain)
|
|
|
|
free(domain);
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
void getstatus_r(faddr *addr, callstat *cst)
|
2001-08-17 05:46:24 +00:00
|
|
|
{
|
2006-01-30 22:27:02 +00:00
|
|
|
FILE *fp;
|
|
|
|
char *temp;
|
2003-02-08 14:21:33 +00:00
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
cst->trytime = 0;
|
|
|
|
cst->tryno = 0;
|
|
|
|
cst->trystat = 0;
|
|
|
|
temp = calloc(PATH_MAX, sizeof(char));
|
|
|
|
stsname_r(addr, temp);
|
2003-02-08 14:21:33 +00:00
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
if ((fp = fopen(temp, "r"))) {
|
|
|
|
fread(cst, sizeof(callstat), 1, fp);
|
2003-02-08 14:21:33 +00:00
|
|
|
fclose(fp);
|
|
|
|
}
|
2006-01-30 22:27:02 +00:00
|
|
|
free(temp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2006-01-30 22:27:02 +00:00
|
|
|
return;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|