home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------*/
- /* */
- /* Module Name: AMAXOUT.C */
- /* Program Name: AMAX */
- /* Revision: 2.xx */
- /* Purpose: Auxiliary Routines for Outbound Checker Module */
- /* Programmer: Alan D. Bryant */
- /* */
- /* Copyright (C) 1988, 89, 90, 92 Alan D. Bryant, All Rights Reserved. */
- /* */
- /* NOTICE: This source code is copyrighted material. You are granted a */
- /* limited license to use and distribute the code. The complete text of */
- /* the license can be found in the document LICENSE.DOC which accompanies */
- /* this source code, or can be obtained directly from the author. */
- /* */
- /* Inquiries regarding this package should be directed to: */
- /* */
- /* AMAX */
- /* Alan D. Bryant */
- /* P. O. Box 101612 */
- /* Denver, CO 80250 */
- /* USA */
- /* */
- /*---------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <ctype.h>
- #include "amax.h"
-
-
- extern unsigned int entries;
-
-
- char *lookinfo(int, int, char, char *);
- char moreinfo(struct list_style *, int, int);
- int select_entry(struct list_style *, int, int);
- int list_contents(FILE *, int, char);
- void show_packet(FILE *);
- void fgetstring(FILE *, char *);
-
- // Returns name and location on successful find, or "Unknown System"
- // on failure. Also displays complete information if mode is true.
- // (mode is true only if display nodelist record contents)
- // This function is also where editing of the nodelist display is
- // implemented. instring is passed when doing a nodelist record
- // edit and the sysop name is already known so it doesn't have to
- // do a lookup. Since the sysop name is part of V7 nodelists, it's
- // a moot point now. It's not been removed because I didn't want
- // to make the corrections in all calling routines.
-
-
-
- char *lookinfo(int looknet, int looknode, char mode, char *instring)
- {
- unsigned int x;
- unsigned int y;
- unsigned int a;
- unsigned int b;
- unsigned int c;
- unsigned long seekval;
- int counter;
-
- int address[3];
- char table[50] = " EANROSTILCHBDMUGPKYWFVJXZQ-'0123456789";
- char temp[100];
- char input[100];
- char disp[100];
- char retstring[100];
- char ch;
-
- FILE *stream;
-
- struct v7fixed {
- unsigned int zone;
- unsigned int net;
- unsigned int node;
- unsigned int hubnode;
- unsigned int callcost;
- unsigned int msgfee;
- unsigned int nodeflags;
- unsigned char modemtype;
- unsigned char phonelen;
- unsigned char passwordlen;
- unsigned char bnamelen;
- unsigned char snamelen;
- unsigned char cnamelen;
- unsigned char packlen;
- unsigned char baudrate;
- } n;
-
-
-
- address[0] = zone_num;
- address[1] = looknet;
- address[2] = looknode;
-
-
- status = cbfind(nodexindex, address, sizeof(address), &item);
-
- if (status == FOUND) {
- fseek(nodexdata, item, SEEK_SET);
- fread(&n, sizeof(n), 1, nodexdata);
- }
- else {
- return "Unknown System";
- }
-
- for (x = 0; x < n.phonelen; x++) {
- ch = fgetc(nodexdata);
- temp[x] = ch;
- }
- temp[x] = 0x00;
-
- strcpy(retstring, "");
-
- if (nlflags & 8) {
- strcat(retstring, temp);
- strcat(retstring, ", ");
- }
-
-
- for (x = 0; x < n.passwordlen; x++) {
- ch = fgetc(nodexdata);
- temp[x] = ch;
- }
- temp[x] = 0x00;
-
- if (nlflags & 16) {
- strcat(retstring, temp);
- strcat(retstring, ", ");
- }
-
-
- for (x = 0; x < n.packlen; x++) {
- a = getw(nodexdata);
- b = a / 40;
- c = a - (b * 40);
- temp[(x * 3) + 2] = table[c];
-
- a = b;
- b = a / 40;
- c = a - (b * 40);
- temp[(x * 3) + 1] = table[c];
-
- a = b;
- b = a / 40;
- c = a - (b * 40);
- temp[(x * 3) + 0] = table[c];
- }
- temp[n.snamelen + n.cnamelen + n.bnamelen] = 0x00;
-
- for (x = 0; x < n.bnamelen; x++) {
- input[x] = temp[x];
- }
- input[x] = 0x00;
-
- if (nlflags & 1) {
- strcat(retstring, input);
- strcat(retstring, ", ");
- }
-
- for (x = 0; x < n.snamelen; x++) {
- input[x] = temp[x + n.bnamelen];
- }
- input[x] = 0x00;
-
- if (nlflags & 4) {
- strcat(retstring, input);
- strcat(retstring, ", ");
- }
-
-
- for (x = 0; x < n.cnamelen; x++) {
- input[x] = temp[x + n.bnamelen + n.snamelen];
- }
- input[x] = 0x00;
-
- if (nlflags & 2) {
- strcat(retstring, input);
- }
- return retstring;
- }
-
-
-
-
-
-
- #include <io.h>
-
- char moreinfo(struct list_style *list, int max, int a)
- {
- FILE *stream;
- FILE *stream2;
-
- int number = 0; /* entry number for moreinfo */
- int x = 0;
- int entry_num;
- int file_entries;
-
- long length;
-
- /* char entry[5] = ""; */
-
- char entry_sel[5] = "";
- char open[150] = "";
- char out[100] = "";
- /*
- char info[60] = "";
- char type[15] = "";
- char flav[20] = "";
- */
- char ch = 0x00;
-
- struct list_style *p;
- struct ftime g;
-
- p = list;
-
- /*
-
- bottomcls(22);
- cursor(22, 0);
- output("Which entry number? ");
- vpanel(4);
- getln(entry, 4);
- for (x = 0; x < strlen(entry); x++) {
- if (entry[x] < 48 || entry[x] > 57) {
- output("Invalid entry...");
- pressanykey();
- return 0;
- }
- }
-
- number = atoi(entry);
-
- if (number < 1 || number > max) {
- output("Entry out of range...");
- pressanykey();
- return 0;
- }
-
- */
-
- number = select_entry(list, max, a);
- if (number == -1) return 0;
- ++number;
-
- /*
-
- bottomcls(4);
- cursor(4, 0);
-
- */
-
- p = p + (number - 1);
-
-
- /*
-
- strcpy(info, lookinfo(p -> net, p -> node, 0));
- strcpy(type, return_type_file(p -> type_file));
- strcpy(flav, return_type_flavor(p -> type_flavor));
-
- sprintf(out, "%03d %5d/%-5d %-34.34s %-10s %-16s\r\n\r\n", number, p -> net,
- p -> node, info, type, flav);
-
- output(out);
-
- */
-
- strcpy(open, outbound);
- strcat(open, p -> filename);
-
- stream = fopen(open, "rb");
- if (stream == NULL) {
- output("Error extracting information about this entry...");
- pressanykey();
- return 0;
- }
-
- getftime(fileno(stream), &g);
- length = filelength(fileno(stream));
-
- fclose(stream);
-
-
-
- // ---------------------------------------------------
-
- x = nlflags;
- nlflags = 15;
- sprintf(out, "To: %s\r\n", lookinfo(p -> net, p -> node, 0, ""));
- output(out);
- nlflags = x;
-
-
-
- strupr(p -> filename);
-
- sprintf(out, "Name: %s Date: %02d/%02d/%02d Time: %02d:%02d Length: %ld\r\n\r\n", p -> filename, g.ft_month, g.ft_day, g.ft_year + 80, g.ft_hour,
- g.ft_min, length);
- output(out);
-
-
- if (p -> type_file == 2 || p -> type_file == 3 || p -> type_file == 6 || p -> type_file == 8) {
- stream = fopen(open, "rb");
- if (stream != NULL) {
- file_entries = list_contents(stream, 8, p -> type_file);
- fclose(stream);
- }
- }
-
- if (p -> type_file == 2 || p -> type_file == 3 || p -> type_file == 8) {
- ch = 0x00;
- while (ch != 'C' && ch != '\r') {
- output("\r\n");
- if (file_entries > 2) output("$1D$0)elete an Entry from File ");
- output("$1C$0)ontinue ");
- if (file_entries > 2) ch = menu_select("DC\r\x1B");
- else ch = menu_select("C\r\x1B");
- if (ch == 0x1B) return 0;
- if (ch == 'D') {
- clearline();
- output("Input entry number: ");
- entry_sel[0] = 0x00;
- vpanel(3);
- getln(entry_sel, 3);
- entry_num = atoi(entry_sel);
- if (entry_num > 0 && entry_num < file_entries) delete_file_ref(entry_num, p -> filename);
- else {
- clearline();
- output("No such entry...please wait...");
- sleep(1);
- clearline();
- }
- stream = fopen(open, "rb");
- if (stream != NULL) {
- file_entries = list_contents(stream, 8, p -> type_file);
- fclose(stream);
- }
- }
- }
- }
-
- if (p -> type_file == 4) {
- stream = fopen(open, "rb");
- if (stream != NULL) {
- sprintf(out, "Call Progress Data: %d Call Attempts %c Bad Connects\r\n",
- getw(stream), p -> filename[11]);
- output(out);
- fclose(stream);
- }
- }
-
- if (p -> type_file == 5 || p -> type_file == 7 || p -> type_file == 9 || p -> type_file == 0x0A) {
- output("Unpack this compressed mail packet for manual handling? ");
- ch = menu_select("YN\r");
- if (ch == 'Y') {
- arcmail(open, p -> net, p -> node);
- cls();
- output("$1AMAX $4View/Edit Outbound Area$0\r\n\r\n");
- print_header();
- return 1;
- }
- }
-
- if (p -> type_file == 4 || p -> type_file == 6 || p -> type_file == 7) {
- output("\r\nPress any key to return to listing... ");
- agetch();
- }
-
- if (p -> type_file == 1) {
- output("Invoke PacketView Mode? $1Y$0)es $1N$0)o ");
- ch = 0x00;
- while (ch != 'Y' && ch != 'N' && ch != 0x1B && ch != 0x0D) {
- ch = agetch();
- if (ch > 90) ch -= 32;
- }
- if (ch == 'Y' || ch == 0x0D) {
- cursor(8, 0);
- clearline();
- stream = fopen(open, "rb");
- if (stream != NULL) {
- show_packet(stream);
- fclose(stream);
- }
- }
-
- cls();
- output("$1AMAX $4View/Edit Outbound Area$0\r\n\r\n");
- print_header();
- }
- return 0;
- }
-
-
-
-
- int select_entry(struct list_style *list, int max, int current)
- {
- extern char extkey;
-
- int x = 0;
- int number = 0;
- int counter = 1;
-
- char ch = 0;
- char entry[5] = "";
- char info[60] = "";
- char out[100] = "";
- char flav[15] = "";
- char type[15] = "";
- char address[20] = "";
-
- struct list_style *p;
-
- p = list;
-
- bottomcls(22);
- cursor(22, 0);
- output("Which entry number? ");
- ch = 0x00;
-
- while (! ch) ch = agetch();
-
- if (ch == 0x18 || ch == 0x19) {
- ch = 0x00;
- while (! ch) {
- cursor(counter + 2, 3);
- output(" ");
- cursor(counter + 4, 3);
- output(" ");
- cursor(counter + 3, 3);
- output("$5*$0");
- ch = agetch();
- if (ch == 0x18) { /* up */
- if (counter > 1) --counter;
- }
- if (ch == 0x19) { /* down */
- if ((counter < 16) && (counter + current < max)) ++counter;
- }
- if (ch == '\r') {
- number = counter + current;
- break;
- }
- ch = 0x00;
- }
- }
-
- else {
-
- if (extkey) {
- entry[0] = ch;
- entry[1] = 0x00;
- }
-
- else ungetch(ch);
-
- vpanel(4);
- getln(entry, 4);
-
- for (x = 0; x < strlen(entry); x++) {
- if (entry[x] < 48 || entry[x] > 57) {
- output("Invalid entry...");
- pressanykey();
- return -1;
- }
- }
- number = atoi(entry);
- }
-
- if (number < 1 || number > max) {
- output("Entry out of range...");
- pressanykey();
- return -1;
- }
-
- bottomcls(4);
- cursor(4, 0);
-
- p = p + (number - 1);
-
- strcpy(info, lookinfo(p -> net, p -> node, 0, NULL));
- strcpy(type, return_type_file(p -> type_file));
- strcpy(flav, return_type_flavor(p -> type_flavor));
-
- sprintf(address, "%d:%d/%d", zone_num, p -> net, p -> node);
-
- if (usenl) sprintf(out, "%03d %-13s %-32.32s %-10s %-14.14s\r\n\r\n", number, address, info, type, flav);
- else sprintf(out, "%03d %-13s %-10s %-14.14s\r\n\r\n", number, address, type, flav);
-
- output(out);
-
- return number - 1;
-
- }
-
-
-
- int list_contents(FILE *stream, int start_pos, char type_file)
- {
-
- FILE *stream2;
- char line[100] = "";
- char out[100] = "";
- char eolarea[3] = "";
- int counter = 0;
- int return_val = 1;
-
- struct ftime g;
- long length;
- unsigned long cum = 0;
-
- bottomcls(start_pos);
- cursor(start_pos, 0);
- output("Contents:\r\n\r\n");
- while(! feof(stream)) {
- fgetln(line, 70, eolarea, stream);
- strupr(line);
- if (strlen(line) > 1) {
- if (counter > 9) {
- output("\r\nPress any key to continue... ");
- agetch();
- bottomcls(start_pos + 2);
- cursor(start_pos + 2, 0);
- counter = 0;
- }
- ++counter;
- sprintf(out, " %d - %s ", return_val, line);
- ++return_val;
- output(out);
- if (type_file == 2) {
- if (isalpha(line[0])) {
- stream2 = fopen(line, "rb");
- }
- else {
- stream2 = fopen(line + 1, "rb");
- }
- if (stream2 != NULL) {
- getftime(fileno(stream2), &g);
- length = filelength(fileno(stream2));
- sprintf(out, "%02d/%02d/%02d %ld bytes", g.ft_month,
- g.ft_day, g.ft_year + 80, length);
- cum = cum + length;
- output(out);
- fclose(stream2);
- }
- else output("???");
- }
- output("\r\n");
- }
- }
- sprintf(out, "\r\nTotal of %ld bytes to be sent.\r\n", cum);
- output(out);
- return return_val;
- }
-
-
- void show_packet(FILE *stream)
- {
- unsigned char out[100];
- unsigned char ch;
- unsigned char input;
- int counter = 0;
- int char_count = 0;
- int success;
- int number = 0;
-
- struct packet_header {
- int origNode;
- int destNode;
- int year;
- int month;
- int day;
- int hour;
- int minute;
- int second;
- int baud;
- int type;
- int origNet;
- int destNet;
- char ProductCode;
- char fill[33];
- } header;
-
- struct packed_message {
- int type;
- int origNode;
- int destNode;
- int origNet;
- int destNet;
- int Attribute;
- int cost;
- char dateTime[20];
- } message;
-
- char toUserName[37];
- char fromUserName[37];
- char subject[73];
-
- cls();
- output("$1AMAX $4PacketView $0");
- fread(&header, sizeof(header), 1, stream);
- output(" This Packet Built by ");
- switch (header.ProductCode) {
- case 0x00:
- output("Fido");
- break;
- case 0x01:
- output("Rover/ConfMail");
- break;
- case 0x05:
- output("Opus/oMMM");
- break;
- case 0x06:
- output("Dutchie");
- break;
- case 0x09:
- output("Hoster");
- break;
- case 0x0C:
- output("FrontDoor");
- break;
- case 0x11:
- output("MailMan");
- break;
- case 0x12:
- output("OOPS");
- break;
- case 0x14:
- output("BGMail");
- break;
- case 0x15:
- output("Crossbow");
- break;
- case 0x19:
- output("BinkScan");
- break;
- case 0x1A:
- output("D'Bridge");
- break;
- case 0x1B:
- output("BinkleyTerm");
- break;
- case 0x1C:
- output("Yankee");
- break;
- case 0x1D:
- output("FGet/Send");
- break;
- case 0x1F:
- output("Polar Bear");
- break;
- case 0x21:
- output("STARgate");
- break;
- case 0x22:
- output("TMail");
- break;
- case 0x23:
- output("TCOMMail");
- break;
- case 0x25:
- output("RBBSMail");
- break;
- case 0x28:
- output("Majik");
- break;
- case 0x29:
- output("Qmail");
- break;
- case 0x2B:
- output("Aurora 3");
- break;
- case 0x2C:
- output("FourDog");
- break;
- case 0x2D:
- output("MSG-PACK");
- break;
- case 0x2E:
- output("AMAX/Aware");
- break;
- case 0x2F:
- output("Domain");
- break;
- case 0x30:
- output("LESRobot");
- break;
- case 0x31:
- output("Rose");
- break;
- case 0x35:
- output("Zmail");
- break;
- case 0x36:
- output("QuickBBS");
- break;
- case 0x37:
- output("BOOM");
- break;
- case 0x3B:
- output("NetGate");
- break;
- case 0x3C:
- output("Odie");
- break;
- case 0x3D:
- output("Quick Gimme");
- break;
- case 0x3E:
- output("dbLink");
- break;
- case 0x3F:
- output("FD/TosScan");
- break;
- case 0x40:
- output("Beagle");
- break;
- case 0x41:
- output("Igor");
- break;
- case 0x42:
- output("TIMS");
- break;
- case 0x43:
- output("Isis");
- break;
- case 0x44:
- output("AirMail");
- break;
- case 0x45:
- output("XRS");
- break;
- default:
- output("Unknown Packer");
- break;
- }
-
-
-
- cursor(2, 0);
-
- while (! feof(stream)) {
- ++number;
- bottomcls(2);
- cursor(2, 0);
- success = fread(&message, sizeof(message) - 20, 1, stream);
- if (success != 1) return;
- fgetstring(stream, message.dateTime);
- fgetstring(stream, toUserName);
- fgetstring(stream, fromUserName);
- fgetstring(stream, subject);
- sprintf(out, "%s ", message.dateTime);
- output(out);
- sprintf(out, " Msg. %d ", number);
- output(out);
- if (message.Attribute & 1) output("(PRIV) ");
- if (message.Attribute & 2) output("(CRASH) ");
- if (message.Attribute & 16) output("(FILE ATT) ");
- if (message.Attribute & 2048) output("(F'REQ) ");
- if (message.Attribute & 4096) output("(RCP REQ) ");
- if (message.Attribute & 8192) output("(RET REQ) ");
- if (message.Attribute & 16384) output("(AUD REQ) ");
- output("\r\n");
-
- sprintf(out, "From: %s of %d/%d\r\n", fromUserName, message.origNet, message.origNode);
- output(out);
-
- sprintf(out, "To: %s of %d/%d\r\n", toUserName, message.destNet, message.destNode);
- output(out);
-
- if (message.Attribute & 16) output("Attch: ");
- else if (message.Attribute & 2048) output("Req: ");
- else output("Re: ");
- sprintf(out, "%s\r\n\r\n", subject);
- output(out);
- ch = 0x01;
- counter = 7;
- while (ch != 0x00 && ! feof(stream)) {
- if (counter == 22) {
- output("\r\n$1Q$0)uit $1C$0)ontinue");
- input = menu_select("QC\x1B\r");
- if (input == 'Q' || input == 0x1B) return;
- bottomcls(7);
- cursor(7, 0);
- counter = 7;
- }
- ch = fgetc(stream);
- if (ch == 0x8D) {
- continue;
- }
- if (ch == 0x0D) {
- output("\r\n");
- ++counter;
- char_count = 0;
- continue;
- }
- if (ch != 0x0A) {
- sprintf(out, "%c", ch);
- output(out);
- ++char_count;
- }
- if (char_count > 60 && ch == ' ') {
- output("\r\n");
- ++counter;
- char_count = 0;
- }
- if (char_count == 75) {
- output("\r\n");
- ++counter;
- char_count = 0;
- }
- }
- output("\r\n\r\n$1Q$0)uit $1C$0)ontinue to Next Packed Message ");
- input = menu_select("QC\x1B\r");
- if (input == 'Q' || input == 0x1B) return;
- }
-
- }
-
-
- void fgetstring(FILE *stream, char *string)
- {
- unsigned char ch = 0x01;
- unsigned int counter = 0;
- while (ch != 0x00 && ! feof(stream)) {
- ch = fgetc(stream);
- string[counter] = ch;
- ++counter;
- }
- if (feof(stream)) string[0] = 0x00;
- return;
- }
-
-
-
-