Fixed nlookup and bfindex for pointlist handling. Added -C config option to utils. Updated man-files
This commit is contained in:
+46
-5
@@ -29,11 +29,12 @@ bool eventexpr(s_expr *expr)
|
||||
static void usage(void)
|
||||
{
|
||||
printf_usage("nodelist compiler",
|
||||
"usage: bfindex [-fh]\n"
|
||||
"usage: bfindex [-fh] [-C config]\n"
|
||||
"\n"
|
||||
"options:\n"
|
||||
" -f force nodelist compiling\n"
|
||||
" -h show this help message\n"
|
||||
" -C config use config\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
@@ -42,6 +43,7 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
|
||||
{
|
||||
s_bni bni;
|
||||
char buf[1024];
|
||||
bool modepoint = FALSE;
|
||||
long countnodes = 0L;
|
||||
long countlines = 0L;
|
||||
enum nodelist_keyword keyword;
|
||||
@@ -52,6 +54,9 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
|
||||
bni.node = addr.node;
|
||||
bni.point = addr.point;
|
||||
|
||||
DEB((D_INDEX, "Start create index for addr: %u:%u/%u.%u", bni.zone,
|
||||
bni.net, bni.node, bni.point));
|
||||
|
||||
if( nodelist_createheader(nlp) == -1 )
|
||||
{
|
||||
log("cannot create nodelist index header");
|
||||
@@ -80,13 +85,16 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
|
||||
|
||||
if( (p = strchr(buf, ',')) )
|
||||
{
|
||||
//DEB((D_INDEX, "index: parse comma: %s", p ));
|
||||
*p++ = '\0';
|
||||
if( (q = strchr(p, ',')) ) *q = '\0';
|
||||
|
||||
}
|
||||
|
||||
if( p == NULL || *p == '\0' )
|
||||
{
|
||||
log("incorrect nodelist line %ld: Short line", countlines);
|
||||
DEB((D_INDEX,"incorrect nodelist line %ld: Short line", countlines));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -94,20 +102,28 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
|
||||
{
|
||||
log("incorrect nodelist line %d: Bad keyword \"%s\"",
|
||||
countlines, buf);
|
||||
DEB((D_INDEX,"incorrect nodelist line %d: Bad keyword \"%s\"",
|
||||
countlines, buf));
|
||||
continue;
|
||||
}
|
||||
|
||||
//DEB((D_INDEX,"index: keyword=%d", keyword));
|
||||
if( keyword == KEYWORD_BOSS )
|
||||
{
|
||||
s_faddr tmpaddr;
|
||||
|
||||
if( ftn_addrparse(&tmpaddr, p, FALSE) )
|
||||
{
|
||||
DEB((D_INDEX,"incorrect nodelist line %ld: Bad boss address \"%s\"",
|
||||
countlines, p));
|
||||
log("incorrect nodelist line %ld: Bad boss address \"%s\"",
|
||||
countlines, p);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEB((D_INDEX,"index: parsing Boss %u:%u/%u.0",
|
||||
tmpaddr.zone, tmpaddr.net, tmpaddr.node));
|
||||
if (addr.point == -1 )
|
||||
modepoint = true;
|
||||
bni.zone = tmpaddr.zone;
|
||||
bni.net = tmpaddr.net;
|
||||
bni.node = tmpaddr.node;
|
||||
@@ -131,36 +147,49 @@ static int nodelist_makeindex(s_nodelist *nlp, s_faddr addr)
|
||||
bni.node = 0;
|
||||
bni.point = 0;
|
||||
bni.hub = 0;
|
||||
modepoint = false;
|
||||
break;
|
||||
case KEYWORD_REGION:
|
||||
bni.net = value;
|
||||
bni.node = 0;
|
||||
bni.point = 0;
|
||||
bni.hub = 0;
|
||||
modepoint = false;
|
||||
break;
|
||||
case KEYWORD_HOST:
|
||||
bni.net = value;
|
||||
bni.node = 0;
|
||||
bni.point = 0;
|
||||
bni.hub = 0;
|
||||
modepoint = false;
|
||||
break;
|
||||
case KEYWORD_HUB:
|
||||
bni.node = value;
|
||||
bni.point = 0;
|
||||
bni.hub = value;
|
||||
modepoint = false;
|
||||
break;
|
||||
case KEYWORD_EMPTY:
|
||||
if (modepoint)
|
||||
{
|
||||
//DEB((D_INDEX,"found empty value=%u",value ));
|
||||
bni.point = value;
|
||||
break;
|
||||
}
|
||||
case KEYWORD_PVT:
|
||||
case KEYWORD_HOLD:
|
||||
case KEYWORD_DOWN:
|
||||
bni.node = value;
|
||||
bni.point = 0;
|
||||
modepoint = false;
|
||||
break;
|
||||
case KEYWORD_POINT:
|
||||
DEB((D_INDEX,"index: kw point"));
|
||||
bni.point = value;
|
||||
break;
|
||||
default:
|
||||
ASSERT_MSG();
|
||||
DEB((D_INDEX,"index: default assert"));
|
||||
}
|
||||
|
||||
if( nodelist_putindex(nlp, &bni) == -1 )
|
||||
@@ -182,10 +211,12 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
s_cval_entry *cfptr;
|
||||
char *nodelistdir = NULL;
|
||||
char *confname = NULL;
|
||||
time_t starttime = 0L;
|
||||
bool forcecompile = FALSE;
|
||||
long countnodes = 0L;
|
||||
char c;
|
||||
int rc = 0;
|
||||
|
||||
/* Initialise random number generation */
|
||||
(void)srand((unsigned)time(0));
|
||||
@@ -193,7 +224,7 @@ int main(int argc, char *argv[])
|
||||
(void)setlocale(LC_ALL, "");
|
||||
/* Set our name (for logging only) */
|
||||
|
||||
while( (c = getopt(argc, argv, "hf")) != (char)-1 )
|
||||
while( (c = getopt(argc, argv, "hfC:")) != (char)-1 )
|
||||
{
|
||||
switch( c ) {
|
||||
case 'f':
|
||||
@@ -202,15 +233,25 @@ int main(int argc, char *argv[])
|
||||
case 'h':
|
||||
usage();
|
||||
exit(0);
|
||||
case 'C':
|
||||
if( confname || !optarg ) { usage(); exit(5); }
|
||||
confname = (char *)xstrcpy(optarg);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(5);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( conf_readconf(conf_getconfname(), 0, false) )
|
||||
|
||||
if( confname && *confname )
|
||||
rc = conf_readconf(confname, 0, false);
|
||||
else
|
||||
rc = conf_readconf(conf_getconfname(), 0, false);
|
||||
|
||||
if( rc )
|
||||
{
|
||||
log("Can not find config");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
+18
-3
@@ -44,7 +44,7 @@ bool eventexpr(s_expr *expr)
|
||||
static void usage(void)
|
||||
{
|
||||
printf_usage("outbound viewer",
|
||||
"usage: bfstat [-afhprst] [-n<number>]\n"
|
||||
"usage: bfstat [-C config] [-afhprst] [-n<number>]\n"
|
||||
"\n"
|
||||
"options:\n"
|
||||
" -a sort by FTN address (default)\n"
|
||||
@@ -56,6 +56,7 @@ static void usage(void)
|
||||
" -r reverse order while sorting\n"
|
||||
" -s sort by total files size\n"
|
||||
" -t disable total sizes printing\n"
|
||||
" -C config use config file\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
@@ -248,8 +249,10 @@ int main(int argc, char *argv[])
|
||||
s_opts opts;
|
||||
s_sysqueue queue;
|
||||
s_outbound_callback_data ocb;
|
||||
char *confname = NULL;
|
||||
char c;
|
||||
int i;
|
||||
int rc = 0;
|
||||
|
||||
bfstat_opts_default(&opts);
|
||||
|
||||
@@ -288,6 +291,10 @@ int main(int argc, char *argv[])
|
||||
if( ISDEC(optarg) )
|
||||
opts.nodeslimit = atoi(optarg);
|
||||
break;
|
||||
case 'C':
|
||||
if( confname || !optarg ) { usage(); exit(BFERR_FATALERROR); }
|
||||
confname = (char *)xstrcpy(optarg);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(1);
|
||||
@@ -301,8 +308,16 @@ int main(int argc, char *argv[])
|
||||
/* Initialise current locale */
|
||||
(void)setlocale(LC_ALL, "");
|
||||
|
||||
if( conf_readconf(conf_getconfname(), 0, false) )
|
||||
exit(1);
|
||||
if( confname && *confname )
|
||||
rc = conf_readconf(confname, 0, false);
|
||||
else
|
||||
rc = conf_readconf(conf_getconfname(), 0, false);
|
||||
|
||||
if( rc )
|
||||
{
|
||||
log("Can not find config");
|
||||
exit(BFERR_FATALERROR);
|
||||
}
|
||||
|
||||
memset(&ocb, '\0', sizeof(s_outbound_callback_data));
|
||||
ocb.callback = out_handle_sysqueue;
|
||||
|
||||
+31
-8
@@ -28,12 +28,13 @@ bool eventexpr(s_expr *expr)
|
||||
static void usage(void)
|
||||
{
|
||||
printf_usage("nodelist lookup utility",
|
||||
"usage: nlookup [-rmh] <address>\n"
|
||||
"usage: nlookup [-C config] [-rmh] <address>\n"
|
||||
"\n"
|
||||
"options:\n"
|
||||
" -r show nodelist string\n"
|
||||
" -m show email address\n"
|
||||
" -h show this help message\n"
|
||||
" -C config use config file\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
@@ -82,7 +83,7 @@ void print_nodeinfo(const s_node *node)
|
||||
timevec_check(&node->worktime, now) ? "false" : "true");
|
||||
}
|
||||
|
||||
if( node->sysop && *node->sysop && strcmp(node->sysop, "<none>") )
|
||||
if( (node->keyword != KEYWORD_POINT) && node->sysop && *node->sysop && strcmp(node->sysop, "<none>") )
|
||||
{
|
||||
char username[BNI_MAXSYSOP+1];
|
||||
|
||||
@@ -127,6 +128,8 @@ int main(int argc, char *argv[])
|
||||
s_node node;
|
||||
s_faddr addr;
|
||||
char ch;
|
||||
int rc = 0;
|
||||
char *confname = NULL;
|
||||
bool rawstring = FALSE;
|
||||
bool emailaddr = FALSE;
|
||||
|
||||
@@ -135,7 +138,7 @@ int main(int argc, char *argv[])
|
||||
/* Initialise current locale */
|
||||
(void)setlocale(LC_ALL, "");
|
||||
|
||||
while( (ch=getopt(argc, argv, "hrm")) != (char)-1 )
|
||||
while( (ch=getopt(argc, argv, "hdrmC:")) != (char)-1 )
|
||||
{
|
||||
switch( ch ) {
|
||||
case 'h':
|
||||
@@ -147,6 +150,10 @@ int main(int argc, char *argv[])
|
||||
case 'm':
|
||||
emailaddr = TRUE;
|
||||
break;
|
||||
case 'C':
|
||||
if( confname || !optarg ) { usage(); exit(BFERR_FATALERROR); }
|
||||
confname = (char *)xstrcpy(optarg);
|
||||
break;
|
||||
default:
|
||||
usage();
|
||||
exit(BFERR_FATALERROR);
|
||||
@@ -159,8 +166,18 @@ int main(int argc, char *argv[])
|
||||
exit(BFERR_FATALERROR);
|
||||
}
|
||||
|
||||
if( conf_readconf(conf_getconfname(), 0, false) )
|
||||
if( confname && *confname )
|
||||
rc = conf_readconf(confname, 0, false);
|
||||
else
|
||||
rc = conf_readconf(conf_getconfname(), 0, false);
|
||||
|
||||
if( rc )
|
||||
{
|
||||
DEB((D_NODELIST,"nlookup: Can not find config"));
|
||||
exit(BFERR_FATALERROR);
|
||||
}
|
||||
|
||||
DEB((D_NODELIST,"Starting nlookup"));
|
||||
|
||||
if( rawstring )
|
||||
{
|
||||
@@ -171,10 +188,16 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else if( nodelist_lookup(&node, addr) == 0 )
|
||||
{
|
||||
if( emailaddr )
|
||||
print_nodemail(&node);
|
||||
else
|
||||
print_nodeinfo(&node);
|
||||
if (addr.point == 0) {
|
||||
if( emailaddr )
|
||||
print_nodemail(&node);
|
||||
else
|
||||
print_nodeinfo(&node);
|
||||
}
|
||||
else
|
||||
{
|
||||
print_nodeinfo(&node);
|
||||
}
|
||||
}
|
||||
|
||||
deinit_conf();
|
||||
|
||||
Reference in New Issue
Block a user