bre thingy
Comx Dlr #1 @1
Sat Aug 27 19:37:22 1994
Mr. Rick #1 @2109
Sun Aug 21 10:48:31 1994

0R: net33: @11012 (via @2001) [01:31 08/23/94]






0R: net33: @2109 [11:09 08/21/94]
Description:

BRESND will take the outgoing net files created by BARON REALMS ELITE,
and convert them to messages that WWIV can deal with.  The receiving side
will parse these messages, and store the data files in BRE's incomming
directory.  I tried to keep it simple - I belive it's a tad easier than
installing Frontdoor :).

Installation:
First, compile br.c & bs.c - "bcc br.c", & "bcc bs.c".
Copy br.exe and bs.exe to your wwiv directory.  Also in your WWIV directory,
Create a file called "bresnd.cfg".  This file needs to have 3 lines:

        1. BRE incomming directory, as defined in plandata.bbs
        2. BRE outgoing directory, as defined in plandata.bbs
        3. Network directory, as defined in wwiv's init program

Be sure to include a trailing backslash.  This is what my bresnd.cfg
looks like:

c:\wwiv\bre\inbound\
c:\wwiv\bre\outbound\
c:\wwiv\hazelnut\

I might add more lines for internetwork games, but not yet...

Next, go to the network directory defined in line 3, and create a file called
"eprogs.net".  This file will consist of a single line:

br 56 56

This tells network2 that br.exe will process all 27/56 type messages.

Then, in your bre directory, edit or create the file "brnodes.dat" - see
the bre docs, it should look something like this:

1
Rick's Cafe' Annex
1/99
St. Pete
MO
USA

2
Rick's Cafe'
1/1
St. Pete
MO
USA

3
The Gatekeeper
1/2
St. Louis
MO
USA


note that the ?/? is supposed to be a fido net/node.  As wwiv doesn't use net
numbers, the first number is irrelavent.  This could be used to support
multiple nets....

Finally, edit your nightly maintenance batch file - add a line

bs

to run the send program.  Of course you can run bs manually, from your
wwiv directory.

Let me know how it works for ya.

                               Mr. Rick
                               WW4NET 1@2109
                               EMAILNET 1@3456
                               HAZELNUT 1@1
                               TOADNET 86:8012/51

(cut here)
/*   br.c - this is the source for the receiver */
#include <stdio.h>
#include <string.h>
#define CHUNK 512
char BREPATH[60];

/*************  define BRE packet header type ******************/
typedef struct{
	 char fn[13];       /* filename 8.3 and terminator */
	 long size;         /* size of file being sent */
	 char resbyte[32];  /* reserved  all zeroes */
}brepkt;

int main(int argc, char *argv[])
{
long numchar;           // an integer variable  (16 bits)
char buf[CHUNK];
FILE *fig,*foo;  // two pointers to FILE structures (defined in stdio.h)
char brepath[80];// an array of 80 chars
brepkt header;
fig=fopen("bresnd.cfg","rt");
if(!fig)
   return -2;
fgets(BREPATH,60,fig);
BREPATH[strlen(BREPATH)-1] = '\0';   // strip the <CR>
fclose(fig);

/******  read the header *************/
if(argc < 2)
  return -1;
printf("BR is processing %s\n",argv[1]);
fig=fopen(argv[1],"rb");                 // open the temp file network2 made
fseek(fig,24,SEEK_SET);
fread(&header,sizeof(brepkt),1,fig);  // and read the header

strcpy(brepath,BREPATH);
strcat(brepath,header.fn);
foo = fopen(brepath,"wb"); // open file
numchar = header.size;
while(numchar > CHUNK)
  {
  fread(buf,CHUNK,1,fig);
  fwrite(buf,CHUNK,1,foo); //write 512 bytes to output file
  numchar -= CHUNK;
  }
fread(buf,numchar,1,fig);
fwrite(buf,numchar,1,foo); // write the rest
fclose(fig);             // close the input file
fclose(foo);             // close our temp file
return 0;
}






Mr. Rick #1 @2109
Sun Aug 21 10:49:26 1994

0R: net33: @11012 (via @2001) [01:31 08/23/94]






0R: net33: @2109 [11:09 08/21/94]
#include <stdio.h>   // file i/o prototypes & structures
#include <dir.h>     // prototypes & structures for file find functions
#include <time.h>    // protos & structs for time functions
#include <string.h>

#define CHUNK 512                                                             
       // buffer size

/*************  define BRE packet header type ******************/
typedef struct{
	 char fn[13];       /* filename 8.3 and terminator */
	 long size;         /* size of file being sent */
	 char resbyte[32];  /* reserved  all zeroes */
}brepkt;

/***********  define FIDOnet message header type ****************/
typedef struct  {
	  char fromUserName[36],
	  toUserName[36],
	  subject[72],
	  dateTime[20];
	  int timesRead,
	  destNode,
	  orgNode,
	  cost,
	  orgNet,
	  destNet,
	  destZone,
	  orgZone,
	  destPoint,
	  orgPoint,
	  replyTo,
	  Attribute,
	  nextReply;
}fidomsg;

/*************** WWIV message header type *********************/
typedef struct {
		  unsigned short  tosys,          /* destination system */
								touser,         /* destination user */
								fromsys,        /* originating system */
								fromuser;       /* originating user */
		  unsigned short  main_type,      /* main message type */
								minor_type;     /* minor message type */
		  unsigned short  list_len;       /* # of entries in system list */
		  unsigned long   daten;          /* date/time sent */
		  unsigned long   length;         /* # of bytes of msg after header */
		  unsigned short  method;         /* method of compression */
} net_header_rec;


/*************  WWIV system record type *********************/
typedef struct {
		  unsigned int    sysnum;         /* system number of the system */
		  char            phone[13],      /* phone number of system */
								name[41];       /* name of system */
		  unsigned int    speed,          /* max baud rate of system */
								other,          /* other info about sys (bit-mapped)*/
								forsys;         /* how to get there */
		  int             numhops;        /* how long to get there */
		  float           cost;           /* how much it costs to get there */
} net_system_list_rec;

void breout(int dest, char *ofile);
int findto(net_system_list_rec *node,unsigned short sys);



char BREPATH[80];
char NETPATH[80];
char mailname[90];


int main()
{
struct ffblk fb;    // file find structure
FILE *in;           // file handle
fidomsg bar;        // Fido message header
char bpath[80];     // search string
char cpath[80];     // fido message filename
int foo;

in = fopen("bresnd.cfg","rt");
if(!in)
	return -1;
fgets(bpath,60,in) ;     // path for incomming, not used

fgets(BREPATH,60,in);    // path for outgoing
BREPATH[strlen(BREPATH)-1] = '\0';
strcpy(bpath,BREPATH);            // path to bre output files
strcat(bpath,"*.msg");            // any fido message file

fgets(NETPATH,60,in);    // path for network #1
NETPATH[strlen(NETPATH)-1] = '\0';
strcpy(mailname,NETPATH);
strcat(mailname,"p56.net");


foo=findfirst(bpath,&fb,0);       // do the search
while(foo==0)                     // findfirst returns 0 on success
	{
	strcpy(cpath,BREPATH);         // build a pathname
	strcat(cpath,fb.ff_name);
	in=fopen(cpath,"rb");          // open the .msg file
	fread(&bar,sizeof(fidomsg),1,in);  // read in the fido message header
    breout(bar.destNode,bar.subject);  // function breout sends the file
    unlink(bar.subject);           // cleanup
	fclose(in);
    unlink(cpath);
	foo=findnext(&fb);             // findnext returns 0 on success...
	}
return 0;
}


void breout(int dest, char *ofile)
{
FILE *foo;
FILE *mail;
char buf[CHUNK];
char cbuf[8];
net_header_rec h;
unsigned numchar,i;
unsigned long flength;
struct ffblk  tmp;
brepkt pkt;
net_system_list_rec q;
time_t l;

if(findfirst(ofile,&tmp,0))
  {
  return;
  }

memset(&pkt,0,sizeof(brepkt));            // initialize headers
memset(&h,0,sizeof(net_header_rec));

/****** setup the network packet header **********/
h.touser = 1;
h.tosys = dest;
h.fromsys = 1;
h.fromuser = 1;
h.main_type=0x1b;        // new extern
h.minor_type=56;        // new type for bre
time(&l);
h.daten=l;
h.method = 0;
h.list_len =0;
h.length = tmp.ff_fsize+sizeof(brepkt);

/******** set up the bre header ************/

strcpy(pkt.fn,tmp.ff_name);        // filename
pkt.size=tmp.ff_fsize;


mail = fopen(mailname,"ab");
foo = fopen(ofile,"rb");
fwrite(&h,sizeof(net_header_rec),1,mail);
fwrite(&pkt,sizeof(brepkt),1,mail);

numchar = tmp.ff_fsize;
while(numchar > CHUNK)
  {
  fread(buf,CHUNK,1,foo);
  fwrite(buf,CHUNK,1,mail); //write 512 bytes to output file
  numchar -= CHUNK;
  }
fread(buf,numchar,1,foo);
fwrite(buf,numchar,1,mail); // write the rest
fclose(foo);
fclose(mail);
return;
}

int findto(net_system_list_rec *node,unsigned short sys)
{
  FILE *net;
  char n[128];
  strcpy(n,NETPATH);
  strcat(n,"bbsdata.net");
  net=fopen(n,"rb");
  while(fread(node,sizeof(net_system_list_rec),1,net))
	 if(node->sysnum == sys)
		{
		fclose(net);
		return 1;
		}
  fclose(net);
  return 0;
}













