Initial nodelist parsing
This commit is contained in:
parent
7cde3b8704
commit
29ebb8277a
@ -66,3 +66,7 @@ NEWSTRING: ""
|
||||
LINE 148 CLEARED
|
||||
OLDSTRING: "Enter the number of a text file to display or Q to quit:"
|
||||
NEWSTRING: ""
|
||||
|
||||
LINE 124 MODIFIED
|
||||
OLDSTRING: "\r\nMailing to %d:%d/%d.%d\r\n"
|
||||
NEWSTRING: "\r\nMailing to %d:%d/%d.%d (%s)\r\n"
|
||||
|
1
dist/config/happynet.ini
vendored
1
dist/config/happynet.ini
vendored
@ -10,6 +10,7 @@ Real Names = false
|
||||
[network]
|
||||
type = fido
|
||||
fido node = 637:1/999
|
||||
domain = happynet
|
||||
|
||||
[General]
|
||||
Read Sec Level = 10
|
||||
|
2
dist/magicka.strings
vendored
2
dist/magicka.strings
vendored
@ -121,7 +121,7 @@ Change Subject? (Y/N)
|
||||
Read message [1-%d] or N for New:
|
||||
\r\nADDR:
|
||||
\r\n\r\nInvalid Address\r\n
|
||||
\r\nMailing to %d:%d/%d.%d\r\n
|
||||
\r\nMailing to %d:%d/%d.%d (%s)\r\n
|
||||
\r\nMailing to @%d\r\n
|
||||
Start at message [1-%d] or N for New?
|
||||
\e[2J\e[1;1H\e[1;37;44m[MSG#] Subject From To Date \r\n\e[0m
|
||||
|
@ -29,7 +29,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -34,7 +34,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -30,7 +30,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -34,7 +34,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && ./configure
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o www_files.o bluewave.o hashmap/hashmap.o menus.o
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o www_files.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -29,7 +29,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -34,7 +34,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -26,10 +26,10 @@ $(JSMN):
|
||||
cd ../deps/jsmn/ && $(MAKE)
|
||||
|
||||
$(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
|
||||
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -31,10 +31,10 @@ $(JSMN):
|
||||
cd ../deps/jsmn/ && $(MAKE)
|
||||
|
||||
$(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/pkg/include && ./configure --with-ncurses
|
||||
cd ../deps/cdk-5.0-20161210/ && export CPPFLAGS=-I/usr/local/include && ./configure --with-ncurses
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o www.o www_email.o www_msgs.o www_last10.o www_files.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -8,7 +8,7 @@ ODOORS = ../deps/odoors/libs-`uname -s`/libODoors.a
|
||||
JSMN = ../deps/jsmn/libjsmn.a
|
||||
CDK = ../deps/cdk-5-20161210/libcdk.a
|
||||
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
|
||||
|
||||
all: magicka magimail magiedit ticproc mgpost magichat fileapprove magiftpd
|
||||
|
||||
|
@ -34,7 +34,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && ./configure
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o www_files.o bluewave.o hashmap/hashmap.o menus.o
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o www_files.o bluewave.o hashmap/hashmap.o menus.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -30,7 +30,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o os/sunos.o
|
||||
OBJ = inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o bluewave.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -34,7 +34,7 @@ $(CDK):
|
||||
cd ../deps/cdk-5.0-20161210/ && ./configure
|
||||
cd ../deps/cdk-5.0-20161210/ && $(MAKE)
|
||||
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o www_files.o hashmap/hashmap.o menus.o os/sunos.o
|
||||
OBJ = ../deps/aha/aha.o ../deps/hashids/hashids.o inih/ini.o bbs.o main.o users.o main_menu.o mail_menu.o doors.o bbs_list.o chat_system.o email.o files.o settings.o lua_glue.o strings.o www.o www_email.o www_msgs.o www_last10.o bluewave.o www_files.o hashmap/hashmap.o menus.o os/sunos.o nodelist.o
|
||||
%.o: %.c $(DEPS)
|
||||
$(CC) -c -o $@ $< $(CFLAGS)
|
||||
|
||||
|
@ -70,6 +70,7 @@ struct mail_conference {
|
||||
char *name;
|
||||
char *path;
|
||||
char *tagline;
|
||||
char *domain;
|
||||
int networked;
|
||||
int nettype;
|
||||
int realnames;
|
||||
@ -366,4 +367,6 @@ extern char *www_create_link(int dir, int sub, int fid);
|
||||
extern char *www_decode_hash(char *hash);
|
||||
#endif
|
||||
extern int menu_system(char *menufile);
|
||||
|
||||
extern char *nl_get_bbsname(struct fido_addr *addr, char *domain);
|
||||
#endif
|
||||
|
@ -2064,6 +2064,7 @@ void post_message(struct user_record *user) {
|
||||
char buffer2[256];
|
||||
int z;
|
||||
int sem_fd;
|
||||
char *bbsname;
|
||||
|
||||
s_JamBase *jb;
|
||||
s_JamMsgHeader jmh;
|
||||
@ -2106,7 +2107,14 @@ void post_message(struct user_record *user) {
|
||||
s_printf(get_string(122));
|
||||
return;
|
||||
}
|
||||
s_printf(get_string(123), from_addr->zone, from_addr->net, from_addr->node, from_addr->point);
|
||||
if (conf.mail_conferences[gUser->cur_mail_conf]->domain != NULL) {
|
||||
bbsname = nl_get_bbsname(from_addr, conf.mail_conferences[gUser->cur_mail_conf]->domain);
|
||||
} else {
|
||||
bbsname = strdup("Unknown");
|
||||
}
|
||||
s_printf(get_string(123), from_addr->zone, from_addr->net, from_addr->node, from_addr->point, bbsname);
|
||||
|
||||
free(bbsname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -327,7 +327,9 @@ static int mail_area_handler(void* user, const char* section, const char* name,
|
||||
}
|
||||
} else if (strcasecmp(name, "fido node") == 0) {
|
||||
mc->fidoaddr = parse_fido_addr(value);
|
||||
}
|
||||
} else if (strcasecmp(name, "domain") == 0) {
|
||||
mc->domain = strdup(value);
|
||||
}
|
||||
} else {
|
||||
// check if it's partially filled in
|
||||
for (i=0;i<mc->mail_area_count;i++) {
|
||||
@ -551,6 +553,7 @@ static int handler(void* user, const char* section, const char* name,
|
||||
conf->mail_conferences[conf->mail_conference_count]->tagline = NULL;
|
||||
conf->mail_conferences[conf->mail_conference_count]->mail_area_count = 0;
|
||||
conf->mail_conferences[conf->mail_conference_count]->nettype = 0;
|
||||
conf->mail_conferences[conf->mail_conference_count]->domain = NULL;
|
||||
conf->mail_conference_count++;
|
||||
} else if (strcasecmp(section, "file directories") == 0) {
|
||||
if (conf->file_directory_count == 0) {
|
||||
|
53
src/nodelist.c
Normal file
53
src/nodelist.c
Normal file
@ -0,0 +1,53 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sqlite3.h>
|
||||
#include "bbs.h"
|
||||
|
||||
extern struct bbs_config conf;
|
||||
|
||||
char *nl_get_bbsname(struct fido_addr *addr, char *domain) {
|
||||
sqlite3 *db;
|
||||
sqlite3_stmt *res;
|
||||
int rc;
|
||||
char buffer[PATH_MAX];
|
||||
char *ret;
|
||||
char *sql_buf = "SELECT bbsname FROM nodelist WHERE nodeno=? AND domain=?";
|
||||
|
||||
snprintf(buffer, PATH_MAX, "%s/nodelists.sq3", conf.bbs_path);
|
||||
|
||||
rc = sqlite3_open(buffer, &db);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
dolog("Cannot open database: %s", sqlite3_errmsg(db));
|
||||
return strdup("Unknown");
|
||||
}
|
||||
sqlite3_busy_timeout(db, 5000);
|
||||
|
||||
rc = sqlite3_prepare_v2(db, sql_buf, -1, &res, 0);
|
||||
|
||||
if (rc != SQLITE_OK) {
|
||||
sqlite3_close(db);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (addr->point == 0) {
|
||||
snprintf(buffer, PATH_MAX, "%d:%d/%d", addr->zone, addr->net, addr->node);
|
||||
} else {
|
||||
// no support for point addresses yet.
|
||||
return strdup("Unknown");
|
||||
}
|
||||
|
||||
sqlite3_bind_text(res, 1, buffer, -1, 0);
|
||||
sqlite3_bind_text(res, 2, domain, -1, 0);
|
||||
|
||||
if (sqlite3_step(res) != SQLITE_ROW) {
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return strdup("Unknown");
|
||||
}
|
||||
ret = strdup(sqlite3_column_text(res, 0));
|
||||
|
||||
sqlite3_finalize(res);
|
||||
sqlite3_close(db);
|
||||
return ret;
|
||||
}
|
124
utils/nodelistp/nodelistp.pl
Executable file
124
utils/nodelistp/nodelistp.pl
Executable file
@ -0,0 +1,124 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
# Contains code by Robert James Clay's FTNDB project. Licensed under the
|
||||
# same license as perl.
|
||||
# https://metacpan.org/source/JAME/App-FTNDB-0.39/bin/ftndb-nodelist
|
||||
|
||||
use DBI;
|
||||
use strict;
|
||||
|
||||
if ($#ARGV < 2) {
|
||||
print "Usage ./nodelistp.pl nodelist database.sq3 domain\n";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
my $nodelist = $ARGV[0];
|
||||
my $database = $ARGV[1];
|
||||
my $domain = $ARGV[2];
|
||||
|
||||
my $driver = "SQLite";
|
||||
my $dsn = "DBI:$driver:dbname=$database";
|
||||
my $userid = "";
|
||||
my $password = "";
|
||||
my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })
|
||||
or die $DBI::errstr;
|
||||
|
||||
my $stmt = qq(CREATE TABLE IF NOT EXISTS nodelist (
|
||||
Id INTEGER PRIMARY KEY,
|
||||
domain TEXT COLLATE NOCASE,
|
||||
nodeno TEXT,
|
||||
sysop TEXT,
|
||||
location TEXT,
|
||||
bbsname TEXT););
|
||||
my $rv = $dbh->do($stmt);
|
||||
|
||||
if($rv < 0){
|
||||
print $DBI::errstr;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
open NODELIST, $nodelist or die print "Cannot open $nodelist";
|
||||
|
||||
$stmt = 'DELETE FROM nodelist WHERE domain=$1;';
|
||||
my $sth = $dbh->prepare( $stmt );
|
||||
$rv = $sth->execute($domain) or die $DBI::errstr;
|
||||
if($rv < 0){
|
||||
print $DBI::errstr;
|
||||
}
|
||||
my $nodelistcount = 0;
|
||||
my $zone = 1;
|
||||
my $net = 0;
|
||||
my $node = 0;
|
||||
my $region = 0;
|
||||
my $location;
|
||||
my $sysop;
|
||||
my $name;
|
||||
my $type;
|
||||
my $number;
|
||||
my $phone;
|
||||
my $bps;
|
||||
my $flags;
|
||||
my $zone_number;
|
||||
my $nodeno;
|
||||
|
||||
while (<NODELIST>) {
|
||||
if ( /^;/ || /^\cZ/ ) {
|
||||
|
||||
# print;
|
||||
next;
|
||||
}
|
||||
|
||||
( $type, $number, $name, $location, $sysop, $phone, $bps, $flags ) =
|
||||
split /,/, $_, 8 ;
|
||||
|
||||
# if $flags is undefined (i.e., nothing after the baud rate)
|
||||
if ( !defined $flags ) {
|
||||
$flags = q{ };
|
||||
}
|
||||
else {
|
||||
$flags =~ s/\r?\n$//; # else remove EOL (removes \r\n or \n but not \r) from $flags
|
||||
}
|
||||
|
||||
if ( $type eq 'Zone' ) { # Zone line
|
||||
$zone = $number;
|
||||
$net = $number;
|
||||
$node = 0;
|
||||
} #
|
||||
elsif ( $type eq 'Region' ) { # Region line
|
||||
$region = $number;
|
||||
$net = $number;
|
||||
$node = 0;
|
||||
}
|
||||
elsif ( $type eq 'Host' ) { # Host line
|
||||
$net = $number;
|
||||
$node = 0;
|
||||
}
|
||||
else {
|
||||
$node = $number;
|
||||
}
|
||||
|
||||
# If zone_number is defined, then go to the next line if the zone
|
||||
# number is not the same as zone_number
|
||||
if (defined $zone_number) {
|
||||
if ($zone != $zone_number) {
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
$name =~ s/\_/ /g;
|
||||
$sysop =~ s/\_/ /g;
|
||||
$location =~ s/\_/ /g;
|
||||
|
||||
$nodeno = "$zone:$net/$node";
|
||||
|
||||
|
||||
$sth = $dbh->prepare('INSERT INTO nodelist (domain, nodeno, sysop, location, bbsname) VALUES($1, $2, $3, $4, $5)');
|
||||
$sth->execute($domain, $nodeno, $sysop, $location, $name);
|
||||
|
||||
$nodelistcount++;
|
||||
}
|
||||
|
||||
close NODELIST;
|
||||
|
||||
print "Processed $nodelistcount nodes.\n";
|
Reference in New Issue
Block a user