home *** CD-ROM | disk | FTP | other *** search
- /*---------------------------------------------------------------------------*/
- /* */
- /* Module Name: AMAXCHEK.C */
- /* Program Name: AMAX */
- /* Revision: 2.xx */
- /* Purpose: Outbound Area Examine / Edit 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 <dir.h>
- #include <dos.h>
- #include <ctype.h>
- #include <sys\stat.h>
- #include <string.h>
- #include "amax.h"
-
- /* function declarations */
-
- int chek(unsigned int, unsigned int, char, char *, char, int);
- void display_section(struct list_style *, int, int);
- char delete_entry(struct list_style *, int);
- char flavor_change(struct list_style *, int);
- char reroute(struct list_style *, int);
- char append_packet(char *, char *);
- char append_attach(char *, char *);
- char *return_type_file(int);
- char *return_type_flavor(int);
- void print_header();
-
- int compare_items_address(struct list_style *, struct list_style *);
- int compare_items_type(struct list_style *, struct list_style *);
- int compare_items_flavor(struct list_style *, struct list_style *);
-
- char *get_fext(char *, char *);
-
- extern char displzero;
-
- int chek(unsigned int our_net, unsigned int our_node, char ARCmail, char *outbound, char sortmode, int location)
- {
- FILE *stream;
-
- /* integer declarations */
-
- int done = 0; /* used for findfirst function */
- unsigned int to_net = 0; /* used to temporarily store net number */
- unsigned int to_node = 0; /* used to temporarily store node number */
- int number_of_items = 0; /* number of items counted */
- int eligible_items = 0; /* number of items we can process */
- int x = 0; /* general incrementing counter */
- int entry_number = 0; /* used in entry selection process */
- int start_place = 1;
- int page_num = 1;
- int total_pages = 1;
-
- /* char declarations */
-
- char open[100];
- char search[60] = ""; /* search string */
- char string[80] = ""; /* general purpose string */
- char filename[13] = ""; /* takes name of file when found */
- char hexname[10] = ""; /* gets first eight digits of filename */
- char stamp[10] = ""; /* first few chars of archive */
- char fext[5] = ""; /* filename extension storage */
- char ch; /* general purpose char */
- char result; /* used for function return values */
- char t;
- char f;
- static char display_limit = 0; /* used for limited displays */
- char disin;
-
- /* struct declarations */
-
- struct list_style *list; /* primary pointer to allocated memory */
- struct list_style *offset; /* secondary pointer, may be indexed */
- struct ffblk ffblk; /* used with findfirst() and findnext () */
-
- /* output screen for user */
-
- cls();
- output("$1AMAX $4View/Edit Outbound Area$0\r\n\r\n");
-
- output("AMAX: Reading outbound area...\r");
-
- /* setup and count all items in outbound area */
-
- strcpy(search, outbound);
- strcat(search, "*.*");
-
- done = findfirst(search, &ffblk, 0);
-
- while (! done) {
- ++number_of_items;
- done = findnext(&ffblk);
- }
-
- /* number_of_items is the number of files in outbound area */
-
- if (number_of_items == 0) {
- output("Your outbound holding area seems to be empty...");
- pressanykey();
- return 0x00;
- }
-
- /* allocate contiguous memory block for structure times files */
-
- list = (struct list_style *) malloc(number_of_items * sizeof(struct list_style));
- offset = list;
-
- /* not enough memory */
-
- if (list == NULL) {
- output("Insufficient memory to Examine/Edit Outbound Area...");
- pressanykey();
- return 0x00;
- }
-
-
- /* The following section of code scans the outbound holding area, */
- /* attempting to make some sort of half-assed guess at what might */
- /* be hiding there. The routine is not intelligent in the least */
- /* since it depends entirely on the assumption that only net files */
- /* that are known to Opus and/or BinkleyTerm will be there. */
- /* A strong chance exists that if someone tries to break AMAX */
- /* by placing other crap in the outbound area that they will */
- /* succeed in their efforts. All the information found is placed */
- /* in the allocated memory in a structure of type list_style. */
- /* */
- /* Here are the codes used for file and flavor types: */
- /* */
- /* File Types Flavor Types */
- /* ---------------------- -------------------- */
- /* 1 - Packet 0 - N/A */
- /* 2 - Attach 1 - Normal */
- /* 3 - Request 2 - Direct */
- /* 4 - Call Progress 3 - Continuous */
- /* 5 - ARCmail 4 - Hold */
- /* 6 - Bad WaZOO 5 - Normal Leave */
- /* 7 - ZOOmail (Not Used) 6 - Direct Leave */
- /* 8 - Update Req Log 7 - Continuous Leave */
- /* 9 - LZHmail 8 - Hold Leave */
- /* A - ZIPmail 9 - Stray */
-
-
- bottomcls(2);
- cursor(2, 0);
-
- done = findfirst(search, &ffblk, 0);
-
- while (! done) {
- strcpy(filename, ffblk.ff_name);
- strupr(filename);
-
- /* if there are not 8 characters in the base name continue */
-
- if (strlen(filename) < 10) {
- done = findnext(&ffblk);
- continue;
- }
-
- /* get (hopefully) the net and node number for the entry */
-
- strncpy(hexname, filename, 8);
- to_net = extractnet(hexname);
- to_node = extractnode(hexname);
-
- t = 0;
- f = 0;
-
- get_fext(filename, fext);
-
- if (! strcmpi(fext, ".OUT")) {
- t = 1;
- f = 1;
- }
- if (! strcmpi(fext, ".DUT")) {
- t = 1;
- f = 2;
- }
- if (! strcmpi(fext, ".CUT")) {
- t = 1;
- f = 3;
- }
- if (! strcmpi(fext, ".HUT")) {
- t = 1;
- f = 4;
- }
- if (! strcmpi(fext, ".NOT")) {
- t = 1;
- f = 5;
- }
- if (! strcmpi(fext, ".NDT")) {
- t = 1;
- f = 6;
- }
- if (! strcmpi(fext, ".NCT")) {
- t = 1;
- f = 7;
- }
- if (! strcmpi(fext, ".NHT")) {
- t = 1;
- f = 8;
- }
- if (! strcmpi(fext, ".FLO")) {
- t = 2;
- f = 1;
- }
- if (! strcmpi(fext, ".DLO")) {
- t = 2;
- f = 2;
- }
- if (! strcmpi(fext, ".CLO")) {
- t = 2;
- f = 3;
- }
- if (! strcmpi(fext, ".HLO")) {
- t = 2;
- f = 4;
- }
- if (! strcmpi(fext, ".NFO")) {
- t = 2;
- f = 5;
- }
- if (! strcmpi(fext, ".NDO")) {
- t = 2;
- f = 6;
- }
- if (! strcmpi(fext, ".NCO")) {
- t = 2;
- f = 7;
- }
- if (! strcmpi(fext, ".NHO")) {
- t = 2;
- f = 8;
- }
- if (! strcmpi(fext, ".REQ")) {
- t = 3;
- f = 0;
- }
- if (strstr(fext, ".$$")) {
- t = 4;
- f = 0;
- }
- if (! strcmpi(fext, ".Z")) {
- t = 6;
- f = 0;
- }
- if (! strcmpi(fext, ".PKT")) {
- t = 1;
- f = 9;
- to_net = 0;
- to_node = 0;
- }
- if (strstr(fext, ".MO")) {
- t = 5;
- f = 0;
- }
- if (strstr(fext, ".TU")) {
- t = 5;
- f = 0;
- }
- if (strstr(fext, ".WE")) {
- t = 5;
- f = 0;
- }
- if (strstr(fext, ".TH")) {
- t = 5;
- f = 0;
- }
- if (strstr(fext, ".FR")) {
- t = 5;
- f = 0;
- }
- if (strstr(fext, ".SA")) {
- t = 5;
- f = 0;
- }
- if (strstr(fext, ".SU")) {
- t = 5;
- f = 0;
- }
- if (strstr(filename, "UPDATE")) {
- t = 8;
- f = 0;
- to_net = 0;
- to_node = 0;
- }
-
- if (display_limit) {
- if (t == 1 && (display_limit & 1)) t = 0;
- if (t == 2 && (display_limit & 2)) t = 0;
- if (t == 3 && (display_limit & 4)) t = 0;
- if (t == 4 && (display_limit & 8)) t = 0;
- if (t == 5 && (display_limit & 16)) t = 0;
- if (t == 6 && (display_limit & 32)) t = 0;
- }
-
-
- if (t == 5) {
- if (ffblk.ff_fsize > 0L) {
- strcpy(open, outbound);
- strcat(open, ffblk.ff_name);
- stream = fopen(open, "rb");
- if (stream == NULL) {
- t = 0;
- }
- else {
- for (x = 0; x < 8; x++) {
- stamp[x] = fgetc(stream);
- }
- fclose(stream);
- t = 0;
- if (stamp[2] == '-' && stamp[3] == 'l' && stamp[4] == 'h') t = 9;
- if (stamp[0] == 'Z') {
- if (t == 0) t = 7;
- }
- if (stamp[0] == 0x1A) {
- if (t == 0) t = 5;
- }
- if (stamp[0] == 'P' && stamp[1] == 'K') {
- if (t == 0) t = 0x0A;
- }
- }
- }
- to_net = our_net - to_net;
- to_node = our_node - to_node;
-
- if (! ARCmail) t = 0;
- if (! displzero && ffblk.ff_fsize == 0L) t = 0;
- }
-
- if (t != 0) {
- offset -> type_file = t;
- offset -> type_flavor = f;
- offset -> net = to_net;
- offset -> node = to_node;
- strcpy(offset -> filename, ffblk.ff_name);
- ++offset;
- ++eligible_items;
- done = findnext(&ffblk);
- continue;
- }
-
- done = findnext(&ffblk);
-
- /* if we don't find what it is, then it'll continue */
-
- } /* end of while loop */
-
- /* In this section, we'll display the items in the outbound area */
- /* in blocks of 16 items. A menu is displayed, and the user can */
- /* select what he wants to do, and to what entry. */
-
- if (eligible_items == 0) {
- output("The outbound area appears to be empty right now...");
- pressanykey();
- display_limit = 0;
- return 0x00;
- }
-
- sortmode = toupper(sortmode);
- if (strchr("ATFN", sortmode)) ch = sortmode;
- else {
- outputi("Sort: $1A$0)ddress $1T$0)ype $1F$0)lavor $1N$0)one");
- ch = menu_select("ATFN\r\x1B");
- }
-
- switch(ch) {
- case '\x1B':
- return 0x00;
- case 'N':
- break;
- case 'A':
- case '\r':
- qsort(list, eligible_items, sizeof(struct list_style), compare_items_address);
- break;
- case 'T':
- qsort(list, eligible_items, sizeof(struct list_style), compare_items_type);
- break;
- case 'F':
- qsort(list, eligible_items, sizeof(struct list_style), compare_items_flavor);
- break;
- }
-
-
-
-
-
-
- print_header();
-
- start_place = (location - 1) * 16;
- if (start_place >= eligible_items) start_place = start_place - 16;
-
- for (x = start_place; x <= eligible_items; x += 16) {
- if (x >= eligible_items) return 0x00;
- /* display_section(list, eligible_items, x); */
-
- cursor(0, 29);
- page_num = (x / 16) + 1;
- total_pages = eligible_items / 16;
- if (eligible_items % 16) ++total_pages;
- sprintf(string, "$0Page %d of %d", page_num, total_pages);
- output(string);
-
- cursor(4, 0);
- display_section(list, eligible_items, x);
-
- cursor(22, 0);
- output("$1D$0)elete $1R$0)eroute $1F$0)lavor $1M$0)ore $1L$0)imit $1C$0)ontinue $1P$0)revious $1Q$0)uit ");
- ch = menu_select("DRFMCQPL\x1B\x1E\x1F\r");
-
- /* process the choice made */
-
- switch (ch) {
- case 'd':
- case 'D':
- entry_number = select_entry(list, eligible_items, x);
- result = delete_entry(list, entry_number);
- if (result) { /* if an entry is deleted, then */
- free(list); /* we'll start over with the */
- return page_num; /* read since info has changed */
- }
- else {
- x = x - 16; /* if a delete operation is not */
- bottomcls(4); /* successful, simply re-display */
- cursor(4, 0); /* the current page of info */
- break;
- }
- case 'L':
- disin = 0x00;
- while (disin != '\r') {
- bottomcls(4);
- cursor(4, 0);
- outputi("\r\nLimit display of items marked below:\r\n\r\n");
- outputi(" 0 - Don't Limit Display\r\n");
- if (display_limit & 1) output("*");
- else output(" ");
- outputi(" 1 - Packets\r\n");
- if (display_limit & 2) output("*");
- else output(" ");
- outputi(" 2 - Attaches\r\n");
- if (display_limit & 4) output("*");
- else output(" ");
- outputi(" 3 - Requests\r\n");
- if (display_limit & 8) output("*");
- else output(" ");
- outputi(" 4 - Call Progress Files\r\n");
- if (display_limit & 16) output("*");
- else output(" ");
- outputi(" 5 - Compressed Mail (Must be Enabled)\r\n");
- if (display_limit & 32) output("*");
- else output(" ");
- outputi(" 6 - Bad WaZOO Files\r\n");
- disin = agetch();
- if (disin == '0') {
- display_limit = 0;
- disin = '\r';
- }
- if (disin == '1') display_limit = display_limit ^ 1;
- if (disin == '2') display_limit = display_limit ^ 2;
- if (disin == '3') display_limit = display_limit ^ 4;
- if (disin == '4') display_limit = display_limit ^ 8;
- if (disin == '5') display_limit = display_limit ^ 16;
- if (disin == '6') display_limit = display_limit ^ 32;
- }
- free(list);
- return page_num;
-
- #if FULLVERSION
- case 'r':
- case 'R':
- entry_number = select_entry(list, eligible_items, x);
- result = reroute(list, entry_number);
- if (result) { /* if a reroute operation is */
- free(list); /* successful, then start over */
- return page_num; /* from the beginning */
- }
- else {
- x = x - 16; /* if a reroute operation is not */
- bottomcls(4); /* successful, or if it's a */
- cursor(4, 0); /* simple rename, re-display the */
- break; /* current page */
- }
-
-
- case 'f':
- case 'F':
- entry_number = select_entry(list, eligible_items, x);
- result = flavor_change(list, entry_number);
- if (result) {
- free(list);
- return page_num;
- }
- else {
- x = x - 16;
- bottomcls(4);
- cursor(4, 0);
- break;
- }
-
- #endif
-
- case 'm':
- case 'M':
- result = moreinfo(list, eligible_items, x);
- if (result) {
- free(list);
- return page_num;
- }
- else {
- x = x - 16;
- bottomcls(4); /* redisplay the current page */
- cursor(4, 0); /* when completed */
- break;
- }
- case 'c':
- case 'C':
- case 0x1F:
- case 0x0D:
- bottomcls(4);
- cursor(4, 0);
- break;
- case 'q':
- case 'Q':
- case 0x1B:
- free(list);
- return 0x00;
- case 'p':
- case 'P':
- case 0x1E:
- if (x == 0) x = x - 16;
- else x = x - 32;
- bottomcls(4);
- cursor(4, 0);
- break;
- } /* end switch */
- } /* end for loop */
-
- /* free allocated memory and return */
-
- free(list);
- return 0x00;
- } /* end of main */
-
-
-
- void display_section(struct list_style *list, int eligible_items, int offset)
- {
- int x = 0;
- int count = 1;
- struct list_style *p;
- char info[60];
- char type[15];
- char flav[25];
- char out[100];
- char address[20];
- char color = 1;
-
- if (offset >= eligible_items) return;
- x = offset;
-
- for (p = list + offset; x <= eligible_items; p++) {
- ++x;
- strcpy(info, (char *) lookinfo(p -> net, p -> node, 0));
- if (p -> type_file == 8) strcpy(info, "Update Request Log");
- if (p -> type_flavor == 9) strcpy(info, "Stray Packet");
- strcpy(type, (char *) return_type_file(p -> type_file));
- strcpy(flav, (char *) return_type_flavor(p -> type_flavor));
- sprintf(address, "%d:%d/%d", zone_num, p -> net, p -> node);
- if (p -> net == 0 && p -> node == 0) sprintf(address, "");
- switch(p -> type_file) {
- case 1:
- color = 1;
- break;
- case 2:
- color = 3;
- break;
- case 3:
- color = 5;
- break;
- case 4:
- color = 7;
- break;
- case 5:
- case 7:
- case 9:
- case 0x0A:
- color = 2;
- break;
- case 6:
- color = 8;
- break;
- default:
- color = 0;
- break;
- }
- if (usenl) sprintf(out, "$%d%03d %-13s %-32.32s %-10s %-14.14s\r\n", color, x, address, info, type, flav);
- else sprintf(out, "$%d%03d %-13s %-10s %-14.14s\r\n", color, x, address, type, flav);
- outputi(out);
- ++count;
- if (count % 17 == 0 || x == eligible_items) return;
- }
- }
-
-
-
- char delete_entry(struct list_style *list, int entry_number)
- {
- FILE *stream;
- FILE *stream2;
-
- char out[100] = "";
- char open[100] = "";
- char line[80] = "";
- char eolarea[3];
- char ch = 0x00;
-
- int x = 0;
-
- struct list_style *p;
-
- p = list + entry_number;
-
- if (entry_number == -1) return 0;
-
- output("Delete this entry? ");
- ch = menu_select("YN");
- aputch(ch);
- if (ch == 'N') return 0;
- output(" Are you sure? ");
- ch = menu_select("YN");
- aputch(ch);
- if (ch == 'N') return 0;
-
- strcpy(open, outbound);
- strcat(open, p -> filename);
-
- if (p -> type_file == 2) {
- stream = fopen(open, "rb");
- while (! feof(stream)) {
- fgetln(line, sizeof(line), eolarea, stream);
- if (line[0] == '#') {
- for (x = 0; x < strlen(line); x++) {
- line[x] = line[x + 1];
- }
- sprintf(out, "\r\nTruncate %s? ", line);
- output(out);
- ch = menu_select("YN");
- aputch(ch);
- if (ch == 'Y') {
- output(" Are you sure? ");
- ch = menu_select("YN");
- aputch(ch);
- if (ch == 'Y') {
- stream2 = fopen(line, "wb");
- fclose(stream2);
- }
- }
- }
- if (line[0] == '^') {
- for (x = 0; x < strlen(line); x++) {
- line[x] = line [x + 1];
- }
- sprintf(out, "\r\nDelete %s? ", line);
- output(out);
- ch = menu_select("YN");
- aputch(ch);
- if (ch == 'Y') {
- output(" Are you sure? ");
- ch = menu_select("YN");
- aputch(ch);
- if (ch == 'Y') {
- unlink(line);
- }
- }
- }
- }
- fclose(stream);
- }
- unlink(open);
- return 1;
- }
-
-
- char *return_type_file(int typenumber)
- {
- switch (typenumber) {
- case 1:
- return "Packet";
- case 2:
- return "Attach";
- case 3:
- return "Request";
- case 4:
- return "Progress";
- case 5:
- return "ARCmail";
- case 6:
- return "Bad WaZOO";
- case 7:
- return "ZOOmail";
- case 8:
- return "Upd Reqs";
- case 9:
- return "LZHmail";
- case 0x0A:
- return "ZIPmail";
- }
- return "";
- }
-
-
-
- char *return_type_flavor(int flavornumber)
- {
- switch (flavornumber) {
- case 0:
- return " ";
- case 1:
- return "Normal";
- case 2:
- return "Direct";
- case 3:
- return "Continuous";
- case 4:
- return "Hold";
- case 5:
- return "Leave Normal";
- case 6:
- return "Leave Direct";
- case 7:
- return "Leave Continuous";
- case 8:
- return "Leave Hold";
- case 9:
- return "Stray";
- }
- return "";
- }
-
-
- #if FULLVERSION
-
- char reroute(struct list_style *list, int entry_number)
- {
- char out[100] = "";
- char compare[100] = "";
- char newpath[80] = "";
- char oldpath[80] = "";
- char lookup[70] = "";
- char address[50] = "";
- char hexname[12] = "";
- char filename[13] = "";
- char input[50] = "";
- char ch = 0x00;
- char result = 0x00;
- char ending[5] = "";
-
- int x = 0;
- int zorig;
-
- struct list_style *p;
- struct ffblk ffblk;
-
- zorig = zone_num;
-
- if (entry_number == -1) return 0;
-
- p = list;
-
- p = p + entry_number;
-
- strcpy(oldpath, outbound);
- strcat(oldpath, p -> filename);
- strcpy(newpath, oldpath);
-
-
- if (p -> type_file > 2) {
- output("\r\nCannot reroute this type of file...");
- pressanykey();
- return 0;
- }
-
- output("Reroute this entry? ");
-
- ch = menu_select("YN");
- aputch(ch);
-
- if (ch == 'N') return 0;
-
- output("\r\n\r\n");
-
- if (p -> type_flavor == 9) {
- strcpy(newpath, outbound);
- strcat(newpath, "00000000.OUT");
- rename(oldpath, newpath);
- strcpy(oldpath, newpath);
- }
-
-
- strcpy(compare, outbound);
-
- output("Reroute this to where (who)? ");
- vpanel(45);
- getln(input, 45);
-
- strcpy(address, input);
-
- if (strlen(address) == 0) return 0;
-
- if (strchr(address, '/') == NULL) {
- strcpy(address, (char *) findaddress(input));
- if (strlen(address) == 0) {
- output("\r\nExpected a Sysop name or node address in the form NET/NODE...press a key...");
- agetch();
- return 0;
- }
- }
-
- strcpy(hexname, (char *) parseaddress(address));
- if (strlen(address) == 0) return 0;
- if (! strcmpi(compare, outbound)) {
- if (p -> net == extractnet(hexname) && p -> node == extractnode(hexname)) {
- output("\r\nWhy reroute this to its current destination?\r\n");
- output("Press any key... ");
- agetch();
- return 0;
- }
- }
- strcpy(lookup, (char *) lookinfo(extractnet(hexname), extractnode(hexname), 0));
- sprintf(out, "Looks like: %s Reroute? ", lookup);
- output(out);
- ch = menu_select("YN");
- aputch(ch);
- if (ch == 'N') {
- newzone(zorig);
- return 0;
- }
-
- strcpy(newpath, outbound);
- strcat(newpath, hexname);
-
- for (x = 0; x < 5; x++ ) {
- ending[x] = oldpath[(strlen(oldpath) - 4) + x];
- }
- ending[x] = 0x00;
-
- strcat(newpath, ending);
-
-
- /* packet */
- /* packet append */
-
- if (p -> type_file == 1 && !findfirst(newpath, &ffblk, 0)) {
- result = append_packet(oldpath, newpath);
- if (result == 0) return 0;
- else {
- newzone(zorig);
- return 1;
- }
- }
-
- /* packet rename */
-
- if (p -> type_file == 1) {
- rename(oldpath, newpath);
- for (x = 0; x < 12; x++) {
- filename[x] = newpath[strlen(newpath) - 12 + x];
- }
- filename[12] = 0x00;
-
- p -> net = extractnet(hexname);
- p -> node = extractnode(hexname);
- strcpy(p -> filename, filename);
- newzone(zorig);
- return 1;
- }
-
- /* attach */
- /* attach append */
-
- if (p -> type_file == 2 && !findfirst(newpath, &ffblk, 0)) {
- result = append_attach(oldpath, newpath);
- if (result == 0) return 0;
- else {
- newzone(zorig);
- return 1;
- }
- }
-
- /* attach rename */
-
- if (p -> type_file == 2) {
- rename(oldpath, newpath);
- for (x = 0; x < 12; x++) {
- filename[x] = newpath[strlen(newpath) - 12 + x];
- }
- filename[12] = 0x00;
-
- p -> net = extractnet(hexname);
- p -> node = extractnode(hexname);
- strcpy(p -> filename, filename);
- newzone(zorig);
- return 1;
- }
- return 0;
-
-
- }
-
-
-
- #endif
-
-
-
- #include <io.h>
-
- char append_packet(char *source_file, char *destin_file)
- {
- FILE *stream;
- FILE *stream2;
- FILE *stream3;
-
- char ch = 0x00;
- char tempfile[13];
- char open[100];
- int x;
- long position;
- long size;
-
-
- if (! stricmp(source_file, destin_file)) return 0;
-
- tmpnam(tempfile);
- strcpy(open, outbound);
- strcat(open, tempfile);
-
- stream = fopen(source_file, "rb");
- if (stream == NULL) return 0;
-
- stream2 = fopen(destin_file, "rb");
- if (stream2 == NULL) {
- fclose(stream);
- return 0;
- }
-
- stream3 = fopen(open, "wb");
- if (stream3 == NULL) {
- fclose(stream);
- fclose(stream2);
- return 0;
- }
-
-
- /* transfer header of destin file to temp */
-
- for (x = 0; x < 58; x++) {
- ch = getc(stream);
- ch = getc(stream2);
- putc(ch, stream3);
- }
-
- while (! feof(stream2)) {
- ch = getc(stream2);
- if (ch == 0x00) {
- if (filelength(fileno(stream2)) - ftell(stream2) > (long) 5) putc(ch, stream3);
- }
- else putc(ch, stream3);
- }
-
- putc(0x00, stream3);
-
- while (! feof(stream)) {
- ch = getc(stream);
- putc(ch, stream3);
- }
-
- fclose(stream);
- fclose(stream2);
- fclose(stream3);
-
- unlink(source_file);
- unlink(destin_file);
- rename(open, destin_file);
-
- return 1;
- }
-
-
- char append_attach(char *source_file, char *destin_file)
- {
- FILE *stream;
- FILE *stream2;
-
- char line[100];
- char eolarea[3];
-
- /* check and see if the source and destination are the same */
- /* and if so, abort the operation and return */
-
- if (! stricmp(source_file, destin_file)) return 0;
-
- /* open files */
-
-
- stream = fopen(source_file, "rb");
-
- if (stream == NULL) {
- return 0;
- }
-
- stream2 = fopen(destin_file, "r+b");
-
- if (stream2 == NULL) {
- fclose(stream);
- return 0;
- }
-
- fseek(stream2, 0L, SEEK_END);
-
- while (! feof(stream)) {
- fgetln(line, sizeof(line), eolarea, stream);
- fprintf(stream2, "%s", line);
- fprintf(stream2, "%c", 0x0A);
- }
-
- fclose(stream);
- fclose(stream2);
- unlink(source_file);
- return 1;
-
- }
-
-
- #if FULLVERSION
-
- char flavor_change(struct list_style *list, int entry_number)
- {
- char ch = 0x00;
-
- char oldname[100] = "";
- char newname[100] = "";
-
- int result;
-
- struct list_style *p;
-
- p = list + entry_number;
-
- if (entry_number == -1) return 0;
-
- if (p -> type_flavor == 0 || p -> type_file > 2 || p -> type_flavor == 9) {
- output("Cannot change flavor of this entry...");
- pressanykey();
- return 0;
- }
-
- output("Change flavor of this entry? ");
- ch = menu_select("YN");
- aputch(ch);
- if (ch == 'N') return 0;
-
- output("\r\n\r\nFlavor: $1N$0)ormal $1D$0)irect $1C$0)ontinuous $1H$0)old $1A$0)bort ");
- ch = menu_select("NDCHA\x1B");
-
- if (ch == 'A' || ch == 0x1B) return 0;
-
- strcpy(oldname, outbound);
- strcat(oldname, p -> filename);
-
- strcpy(newname, oldname);
-
- switch (ch) {
- case 'N':
- if (p -> type_file == 1) {
- if (p -> type_flavor > 4) newname[strlen(newname) - 2] = 'O';
- else newname[strlen(newname) - 3] = 'O';
- }
- else {
- if (p -> type_flavor > 4) newname[strlen(newname) - 2] = 'F';
- else newname[strlen(newname) - 3] = 'F';
- }
- output("Normal");
- break;
- case 'D':
- if (p -> type_flavor > 4) newname[strlen(newname) - 2] = 'D';
- else newname[strlen(newname) - 3] = 'D';
- output("Direct");
- break;
- case 'C':
- if (p -> type_flavor > 4) newname[strlen(newname) - 2] = 'C';
- else newname[strlen(newname) - 3] = 'C';
- output("Continuous");
- break;
- case 'H':
- if (p -> type_flavor > 4) newname[strlen(newname) - 2] = 'H';
- else newname[strlen(newname) - 3] = 'H';
- output("Hold");
- break;
- }
-
- result = rename(oldname, newname);
-
- if (! result) {
- output("\r\n\r\nFlavor changed...");
- pressanykey();
- return 1;
- }
-
- if (p -> type_file == 1) {
- if (append_packet(oldname, newname)) {
- output("\r\n\r\nAppended packet to existing packet of same type. ");
- }
- else {
- output("\r\n\r\nPacket is already designated flavor! ");
- }
- }
- else {
- if (append_attach(oldname, newname)) {
- output("\r\n\r\nAppended attach to existing attach of same type. ");
- }
- else {
- output("\r\n\r\nAttach is already designated flavor! ");
- }
- }
-
- output("Press any key... ");
- agetch();
-
- return 1;
-
- }
-
-
- #endif
-
- void print_header()
- {
- /* output header */
-
- cursor(2, 0);
-
- if (usenl) {
- output("No Zone:Net/Node System Name and Location Type Flavor\r\n");
- output("--- ------------- -------------------------------- ---------- --------------$0\r\n");
- }
-
- if (! usenl) {
- output("No Zone:Net/Node Type Flavor \r\n");
- output("--- ------------- ---------- --------------\r\n");
- }
-
-
-
-
- }
-
-
- int compare_items_address(struct list_style *x, struct list_style *y)
- {
- if (x -> net > y -> net) return 1;
- if (x -> net < y -> net) return -1;
- if (x -> node > y -> node) return 1;
- if (x -> node < y -> node) return -1;
- if (x -> type_file > y -> type_file) return 1;
- if (x -> type_file < y -> type_file) return -1;
- if (x -> type_flavor > y -> type_flavor) return 1;
- if (x -> type_flavor < y -> type_flavor) return -1;
- return 0;
- }
-
- int compare_items_type(struct list_style *x, struct list_style *y)
- {
- if (x -> type_file > y -> type_file) return 1;
- if (x -> type_file < y -> type_file) return -1;
- if (x -> type_flavor > y -> type_flavor) return 1;
- if (x -> type_flavor < y -> type_flavor) return -1;
- if (x -> net > y -> net) return 1;
- if (x -> net < y -> net) return -1;
- if (x -> node > y -> node) return 1;
- if (x -> node < y -> node) return -1;
- return 0;
- }
-
-
- int compare_items_flavor(struct list_style *x, struct list_style *y)
- {
- if (x -> type_flavor > y -> type_flavor) return 1;
- if (x -> type_flavor < y -> type_flavor) return -1;
- if (x -> type_file > y -> type_file) return 1;
- if (x -> type_file < y -> type_file) return -1;
- if (x -> net > y -> net) return 1;
- if (x -> net < y -> net) return -1;
- if (x -> node > y -> node) return 1;
- if (x -> node < y -> node) return -1;
- return 0;
- }
-
- char *get_fext(char *filename, char *fileext)
- {
- fnsplit(filename, NULL, NULL, NULL, fileext);
-
- return "";
- }
-
-