home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
OS2OMMM.SRC
/
OMMMSCAN.C
< prev
next >
Wrap
Text File
|
1989-06-01
|
7KB
|
236 lines
/***************************************************************************/
/*** ***/
/*** oMMM - The Outbound Matrix Message Masher ***/
/*** Copyright 1989 BS Software ***/
/*** ***/
/*** FILENAME: OMMMSCAN.C ***/
/*** ***/
/*** Mail area scanner ***/
/*** ***/
/*** Based on the original oMMM, a portion of ***/
/*** the Opus Computer-Based Conversation System ***/
/*** Copyright 1986, Wynn Wagner III ***/
/*** ***/
/***************************************************************************/
/*** ***/
/*** Tabs set at every 4th column ***/
/*** ***/
/***************************************************************************/
/*
Polytron Version Control System Comments:
The revision of this file is *** $Revision: 1.40 $ ***
History of changes from 1.30 release version
$Log: C:/OMMM/PROJFILE/OMMMSCAN.C_V $
*
* Rev 1.40BP 2 June 1989 23:19:00 Bill Andrus
* Public Release Version 1.40BP (OS/2 Protect Mode, Bound)
*
* Rev 1.40 12 Feb 1989 4:56:16 Marshall Presnell
* Public Release Version 1.40
*
* Rev 1.31 31 Jan 1989 0:58:20 Marshall Presnell
* oMMM 1.35 Beta Release Version
*
* Rev 1.30 23 Jan 1989 17:53:58 Marshall Presnell
* Public Source Code Release - Version 1.30
*/
/*--------------------------------------------------------------------------*/
/* Include files */
/*--------------------------------------------------------------------------*/
#include "ommm.h"
#include <stdlib.h>
#include <string.h>
/*--------------------------------------------------------------------------*/
/* Static function declarations */
/*--------------------------------------------------------------------------*/
static struct _pending * find_pointer(struct _pending *,int);
static void find_addr(struct _msg * msg);
/*--------------------------------------------------------------------------*/
/* Static variable definitions */
/*--------------------------------------------------------------------------*/
static struct _pending * temppend;
static char mjunk[16000];
/*--------------------------------------------------------------------------*/
/* External variable declarations */
/*--------------------------------------------------------------------------*/
extern NETADDRESS ctlnet[];
extern int num_addrs;
/****************************************************************************/
/*--------------------------------------------------------------------------*/
/* FIND POINTER */
/*--------------------------------------------------------------------------*/
static struct _pending *
find_pointer(struct _pending * rootptr,int number)
{
register struct _pending * tree;
register struct _msglist * mlist;
struct _msglist * tmp;
tree = rootptr;
while(tree) {
if ((tree->id1==dest.net) && (tree->id2==dest.node) && (tree->id3==dest.zone)) {
mlist = tree->lastmsg;
tmp = (struct _msglist *) malloc(sizeof(struct _msglist));
tmp->number = number;
while (mlist->number < number) {
if (mlist->next == NULL) {
tmp->next = NULL;
mlist->next = tmp;
return(NULL);
} else
mlist = mlist->next;
}
tmp->next = mlist;
tmp->prev = mlist->prev;
if (mlist->prev) {
mlist->prev->next = tmp;
mlist->prev = tmp;
} else {
mlist->prev = tmp;
tree->lastmsg = tree->firstmsg = tmp;
}
return (NULL);
}
tree = tree->next;
}
tree = (struct _pending *) malloc(sizeof(struct _pending));
tree->id1 = dest.net;
tree->id2 = dest.node;
tree->id3 = dest.zone;
tree->firstmsg = tree->lastmsg = NULL;
tree->firstmsg = tree->lastmsg = (struct _msglist *)malloc(sizeof(struct _msglist));
(tree->firstmsg)->number= (tree->lastmsg)->number = number;
(tree->firstmsg)->next = (tree->lastmsg)->next = NULL;
(tree->firstmsg)->prev = (tree->lastmsg)->prev = NULL;
tree->next = rootptr;
return(tree);
}
/*--------------------------------------------------------------------------*/
/* SCAN MESSAGES */
/*--------------------------------------------------------------------------*/
int
scan_messages()
{
int loci;
struct _msg * msg;
msg = (struct _msg *) mjunk;
sprintf(template,"%s*.MSG",message_path);
if (dir_findfirst(template,NORMAL,&dta)) {
printf("\nNo messages (%s)\n",message_path);
return(0);
}
/*--------------------------------------------------------------------*/
/* Scan for outbound messages */
/*--------------------------------------------------------------------*/
puts("Scanning mail area...");
do {
if (dta.size < (long) sizeof(struct _msg))
continue;
if ((j=atoi(dta.name)) <= 0)
continue;
sprintf(template,"%s%s",message_path,dta.name);
if (open_read_and_close(template,mjunk,16000) < 0) {
printf("Can't read %s\n",template);
continue;
}
/* If we are not supposed to forward, then don't! */
if (noforward) {
for (loci = 0; loci < num_addrs; loci++) {
if ((msg->orig_net == ctlnet[loci].net) &&
(msg->orig == ctlnet[loci].node)) {
break;
}
}
if (loci == num_addrs) {
continue;
}
}
if ((msg->dest_net>=0) && (!(msg->attr&MSGSENT)) && (!(msg->attr&MSGORPHAN))) {
find_addr (msg);
for (loci = 0; loci < num_addrs; loci++) {
if ((dest.net == ctlnet[loci].net) && (dest.node == ctlnet[loci].node)) {
break;
}
}
if (loci == num_addrs) {
if (root) {
if (NULL!=(temppend=find_pointer(root,j)))
root = temppend;
} else {
root = (struct _pending *)malloc(sizeof(struct _pending));
root->next = NULL;
root->id1 = dest.net;
root->id2 = dest.node;
root->id3 = dest.zone;
root->firstmsg = root->lastmsg = (struct _msglist *)malloc(sizeof(struct _msglist));
(root->firstmsg)->number=(root->lastmsg)->number=j;
(root->firstmsg)->next=(root->lastmsg)->next=NULL;
(root->firstmsg)->prev=(root->lastmsg)->prev=NULL;
}
}
}
} while(!dir_findnext(&dta));
return(1);
}
/*--------------------------------------------------------------------------*/
/* FIND ADDR */
/*--------------------------------------------------------------------------*/
static void
find_addr(struct _msg * msg)
{
char * p;
dest.zone = our_zone;
p = strstr(&mjunk[sizeof (struct _msg)], "\001INTL");
if ((p == NULL) || (our_zone == 0) || ((use_gates) && (!(msg->attr&(MSGCRASH|MSGFILE|MSGFRQ|MSGURQ))))) {
dest.net = msg->dest_net;
dest.node = msg->dest;
} else {
sscanf(p+6, "%d:%d/%d", &(dest.zone), &(dest.net), &(dest.node));
}
if ((our_zone == msg->dest_net) && (dest.zone == msg->dest)) {
dest.net = msg->dest_net;
dest.node = msg->dest;
dest.zone = our_zone;
}
}
/*--------------------------------------------------------------------------*/
/* END OF FILE */
/*--------------------------------------------------------------------------*/