Release 0.95.11, patches by Scott Street. Netmail nodelist sysop lookup added and some fixes
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $Id: nntp.c,v 1.16 2008/12/28 12:20:14 mbse Exp $
|
||||
* Purpose ...............: MBSE BBS Internet Library
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2005
|
||||
* Copyright (C) 1997-2011
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@@ -249,7 +248,7 @@ int nntp_cmd(char *cmd, int resp)
|
||||
if (strncmp(p, rsp, strlen(rsp))) {
|
||||
WriteError("NNTP> %s", cmd);
|
||||
WriteError("NNTP< %s", p);
|
||||
memset(&resp, 0, sizeof(rsp));
|
||||
memset(rsp, 0, sizeof(rsp));
|
||||
strncpy(rsp, p, 3);
|
||||
return atoi(rsp);
|
||||
}
|
||||
|
@@ -1162,3 +1162,89 @@ retdummy:
|
||||
}
|
||||
|
||||
|
||||
|
||||
node_list *searchSysop( char *SysopName )
|
||||
{
|
||||
char nodeuserpath[256];
|
||||
FILE *fp;
|
||||
char fixedSysopName[36];
|
||||
nlusr nluEntry;
|
||||
faddr addr;
|
||||
node_list *result;
|
||||
node *nlEntry;
|
||||
|
||||
Syslog('n', "searchSysop: Arg(%s) started", SysopName );
|
||||
|
||||
result = NULL;
|
||||
snprintf(nodeuserpath, 256, "%s/%s", CFG.nodelists, "node.users");
|
||||
if ((fp = fopen(nodeuserpath, "r")) == NULL) {
|
||||
WriteError("$Can't open %s", nodeuserpath);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* fixup incoming sysop name to have _ for space
|
||||
*/
|
||||
memset( fixedSysopName, 0, 36 );
|
||||
int i;
|
||||
for ( i=0; i<strlen( SysopName ); i++ ){
|
||||
if ( SysopName[i] == ' ' ){
|
||||
fixedSysopName[i] = '_';
|
||||
} else {
|
||||
fixedSysopName[i] = SysopName[i];
|
||||
}
|
||||
}
|
||||
|
||||
while (fread(&nluEntry, sizeof(nluEntry), 1, fp) == 1) {
|
||||
|
||||
if ( strcmp( fixedSysopName, nluEntry.user ) == 0 ){
|
||||
|
||||
addr.zone = nluEntry.zone;
|
||||
addr.net = nluEntry.net;
|
||||
addr.node = nluEntry.node;
|
||||
addr.point = nluEntry.point;
|
||||
addr.name = fixedSysopName;
|
||||
addr.domain = NULL;
|
||||
|
||||
nlEntry = getnlent( &addr );
|
||||
if ( NULL == nlEntry ) {
|
||||
/* yikes */
|
||||
Syslog('n',"searchSysop: Something terribly wrong happened with getnlent looking up (%d:%d/%d.%d)",
|
||||
addr.zone, addr.net, addr.node, addr.point );
|
||||
return NULL;
|
||||
}
|
||||
Syslog('n',"searchSysop: found NL Entry: Name:(%s) @ (%s)", nlEntry->name, nlEntry->location);
|
||||
|
||||
node_list *thisresult = result;
|
||||
if (thisresult == NULL) {
|
||||
result = malloc( sizeof(node_list));
|
||||
result->next = NULL;
|
||||
thisresult = result;
|
||||
} else {
|
||||
while ( thisresult->next != NULL ){
|
||||
thisresult = thisresult->next;
|
||||
}
|
||||
thisresult->next = malloc( sizeof(node_list));
|
||||
thisresult = thisresult->next;
|
||||
thisresult->next = NULL;
|
||||
}
|
||||
thisresult->addr.zone = nlEntry->addr.zone;
|
||||
thisresult->addr.net = nlEntry->addr.net;
|
||||
thisresult->addr.node = nlEntry->addr.node;
|
||||
thisresult->addr.point = nlEntry->addr.point;
|
||||
strcpy( thisresult->Sysop, nlEntry->sysop );
|
||||
strcpy( thisresult->Location, nlEntry->location);
|
||||
strcpy( thisresult->Name, nlEntry->name );
|
||||
|
||||
}
|
||||
if ( nluEntry.user[0] > fixedSysopName[0] ) { // Since list is sorted, abort once we get names that start after this one
|
||||
break;
|
||||
}
|
||||
}
|
||||
fclose( fp );
|
||||
|
||||
Syslog('n', "searchSysop: Arg(%s) ended", SysopName );
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -41,6 +41,16 @@ typedef struct _node {
|
||||
|
||||
|
||||
|
||||
typedef struct _node_list {
|
||||
struct _node_list *next;
|
||||
faddr addr;
|
||||
char Name[80];
|
||||
char Sysop[80];
|
||||
char Location[80];
|
||||
} node_list;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Memory array structures read from nodelist.conf
|
||||
*/
|
||||
@@ -122,7 +132,7 @@ nodelist_service *nl_service;
|
||||
int initnl(void);
|
||||
void deinitnl(void);
|
||||
node *getnlent(faddr *);
|
||||
|
||||
node_list *searchSysop(char *);
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user