home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------*/
- /* */
- /* Module Name: AMAXBOMB.C */
- /* Program Name: AMAX */
- /* Revision: 2.xx */
- /* Purpose: Mailing List 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 <dos.h>
- #include <dir.h>
- #include <stdio.h>
- #include <string.h>
- #include "amax.h"
-
-
- void bomb(int, int, char *);
-
- void bomb(int from_net, int from_node, char *sysop) {
-
- FILE *stream;
- FILE *stream2;
-
- static char list[100] = "PLEASE.ALL";
- char key[60] = "";
- char ch = 0x00;
- int done = 0;
- int finished = 0;
- int to_net = 0;
- int to_node = 0;
- struct ffblk ffblk;
- char fileopen[100] = "";
- char file[100] = "";
- char path[100] = "";
- char line[100] = "";
- char destination[100] = "";
- char part[50] = "";
- char name[50] = "";
- char eolarea[3] = "";
- char hexname[15] = "";
- char suffix[5] = "";
- char *position;
- char begin = 1;
- char out[100];
-
- cls();
- output("$1AMAX $4Send Message or File to Mailing List Members$0");
- cursor(2, 0);
-
- output("Enter name of list file: ");
- vpanel(50);
- getln(list, 50);
-
- if (strlen(list) == 0) return;
-
- done = findfirst(list, &ffblk, 0);
- if (done) {
- output("Invalid list file name...");
- strcpy(list, NULL);
- pressanykey();
- return;
- }
-
-
- output("\r\n$1L$0)ist Choices $1C$0)ontinue ");
- ch = menu_select("LC\x1B\r");
- if (ch == 0x1B) return;
- if (ch == 'L') {
- stream = fopen(list, "rb");
- if (stream != NULL) {
- cursor(4, 0);
- clearline();
- while (! feof(stream)) {
- fscanf(stream, "%s", part);
- if (done == 10) {
- done = 0;
- output("\r\nTo continue, ");
- pressanykey();
- bottomcls(4);
- cursor(4, 0);
- sprintf(out, "%s (Continued)\r\n", strupr(key));
- if (! strchr(part, '.')) output(out);
- }
- if (strchr(part, '.')) {
- begin = 1;
- continue;
- }
- if (part[0] == ';') {
- fgetln(line, sizeof(line), eolarea, stream);
- continue;
- }
- if (! strchr(part, '/') && begin) {
- if (! strcmp(key, part)) continue;
- sprintf(out, "%s\r\n", strupr(part));
- output(out);
- strcpy(name, part);
- strcpy(key, part);
- ++done;
- begin = 0;
- continue;
- }
- else {
- if (strcmpi(name, part)) {
- sprintf(out, " %s\r\n", part);
- output(out);
- ++done;
- }
- }
- }
- if (done != 0) {
- output("\r\nTo continue, ");
- pressanykey();
- }
- fclose(stream);
- }
- }
-
- bottomcls(3);
- cursor(3, 0);
-
- key[0] = 0x00;
- output("\r\nEnter list keyword: ");
- vpanel(25);
- getln(key, 25);
-
- if (strlen(key) == 0) return;
-
- output("Perform list send of: $1M$0)essage and/or File $1F$0)ile Only ");
- ch = menu_select("MF\x1B");
- if (ch == 0x1B) return;
-
- if (ch == 'M') {
- qmsg(from_net, from_node, sysop, 1, list, key);
- output("\r\nOperation completed or aborted...");
- pressanykey();
- return;
- }
- else {
- output("\r\n\r\nEnter path and name of file to send: ");
- vpanel(40);
- getln(file, 40);
- if (strlen(file) == 0) return;
-
- done = findfirst(file, &ffblk, 0);
- if (done) {
- output("I don't find this file...");
- pressanykey();
- return;
- }
- output("Flavor: $1C$0)ontinuous $1D$0)irect $1N$0)ormal $1H$0)old ");\
- ch = menu_select("CDNH\x1B");
- if (ch == 0x1B) return;
- if (ch == 'C') strcpy(suffix, ".CLO");
- if (ch == 'D') strcpy(suffix, ".DLO");
- if (ch == 'N') strcpy(suffix, ".FLO");
- if (ch == 'H') strcpy(suffix, ".HLO");
- ch = 0;
- minicls();
- cursor(2, 0);
- output("Sending file to list members...\r\n\r\n");
- stream = fopen(list, "rb");
- while (! feof(stream)) {
- fscanf(stream, "%s", part);
- if (! strcmp(part, ";")) fgetln(line, sizeof(line), eolarea, stream);
- if (! stricmp(part, key)) {
- while (strcmp(part, ".")) {
- fscanf(stream, "%s ", part);
- if (! strcmp(part, ".")) continue;
- strcpy(hexname, (char *) parseaddress(part));
- to_node = extractnode(hexname);
- to_net = extractnet(hexname);
- if (to_net == 0 && to_node == 0) continue;
- ++ch;
- if (ch > 12) {
- bottomcls(4);
- cursor(4, 0);
- ch = 0;
- }
- strcpy(fileopen, outbound);
- strcat(fileopen, hexname);
- strcat(fileopen, suffix);
- done = findfirst(fileopen, &ffblk, 0);
- if (! done) {
- strcpy(destination, fileopen);
- fileopen[strlen(fileopen) - 3] = 'T';
- stream2 = fopen(fileopen, "wb");
- if (stream2 == NULL) {
- output("Unrecoverable file error...");
- pressanykey();
- fclose(stream);
- return;
- }
- finished = findfirst(file, &ffblk, 0);
- while (! finished) {
- position = (char *) strrchr(file, 0x5C);
- if (position == NULL) strcpy(path, "");
- else {
- strcpy(path, file);
- position = (char *) strrchr(path, 0x5C);
- position[1] = 0x00;
- }
- if (strlen(path) != 0) fprintf(stream2, "%s", path);
- fprintf(stream2, "%s", ffblk.ff_name);
- fprintf(stream2, "%c", 0x0A);
- finished = findnext(&ffblk);
- }
- fclose(stream2);
- sprintf(line, "Appending existing attach for %d/%d\r\n", to_net, to_node);
- output(line);
- append_attach(fileopen, destination);
- }
- else {
- sprintf(line, "Creating new attach for %d/%d\r\n", to_net, to_node);
- output(line);
- stream2 = fopen(fileopen, "wb");
- if (stream2 == NULL) {
- output("Unrecoverable file error...");
- pressanykey();
- fclose(stream);
- return;
- }
- finished = findfirst(file, &ffblk, 0);
- while (! finished) {
- position = (char *) strrchr(file, 0x5C);
- if (position == NULL) strcpy(path, "");
- else {
- strcpy(path, file);
- position = (char *) strrchr(path, 0x5C);
- position[1] = 0x00;
- }
- if (strlen(path) != 0) fprintf(stream2, "%s", path);
- fprintf(stream2, "%s", ffblk.ff_name);
- fprintf(stream2, "%c", 0x0A);
- finished = findnext(&ffblk);
- }
- fclose(stream2);
- }
- }
- }
- }
- output("Operation complete...");
- pressanykey();
- return;
- }
- }
-
-