home *** CD-ROM | disk | FTP | other *** search
- /*--------------------------------------------------------------------------*/
- /* */
- /* */
- /* ------------ Bit-Bucket Software <no-Inc> */
- /* \ 10001101 / Writers and Distributors of */
- /* \ 011110 / No-Cost<no-tm> Software. */
- /* \ 1011 / */
- /* ------ */
- /* */
- /* Copyright (C) 1987, 1988, 1989 by Robert Hartman and Vincent Perriello */
- /* */
- /* */
- /* This module was written by Vince Perriello */
- /* */
- /* */
- /* BinkleyTerm External Protocol Handler Module */
- /* */
- /* */
- /* For complete details of the licensing restrictions, please refer */
- /* to the License agreement, which is published in its entirety in */
- /* the MAKEFILE and BT.C, and also contained in the file LICENSE.210. */
- /* */
- /* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
- /* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
- /* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
- /* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT THE AUTHORS */
- /* AT THE ADDRESSES LISTED BELOW. IN NO EVENT SHOULD YOU PROCEED TO */
- /* USE THIS FILE WITHOUT HAVING ACCEPTED THE TERMS OF THE */
- /* BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER AGREEMENT AS YOU */
- /* ARE ABLE TO REACH WITH THE AUTHORS. */
- /* */
- /* */
- /* The Authors can be reached at the following addresses: */
- /* */
- /* Robert C. Hartman Vincent E. Perriello */
- /* Spark Software VEP Software */
- /* 427-3 Amherst Street 111 Carroll Street */
- /* CS2032, Suite 232 Naugatuck, CT 06770 */
- /* Nashua, NH 03061 */
- /* */
- /* FidoNet 1:132/101 FidoNet 1:141/491 */
- /* Data (603) 888-8179 Data (203) 729-7569 */
- /* */
- /* Please feel free to contact us at any time to share your comments */
- /* about our software and/or licensing policies. */
- /* */
- /*--------------------------------------------------------------------------*/
-
- #include <stdio.h>
- #include <signal.h>
- #include <ctype.h>
- #include <conio.h>
- #include <string.h>
- #include <process.h>
-
- #ifdef __TURBOC__
- #include <alloc.h>
- #else
- #include <malloc.h>
- #endif
-
- #include "com.h"
- #include "xfer.h"
- #include "zmodem.h"
- #include "keybd.h"
- #include "sbuf.h"
- #include "sched.h"
- #include "externs.h"
- #include "prototyp.h" /*PLF Fri 05-05-1989 05:50:32.
- * had to truncate #include file name to
- * 8 chars. */
-
- void do_extern (cmd, prot, name)
- char *cmd; /* "Get" or "Send" */
- char prot; /* 1st letter of proto */
- char *name; /* Name of file */
- {
- int i, j;
- char junk[100];
- char *c, *p, *m;
- FILE *ctlfile;
-
- for (j = 0; j < 100; j++) /* Make sure it's all */
- junk[j] = '\0'; /* zeroes... */
-
- for (j = 0; j < 5; j++)
- {
- if (protos[j].first_char == prot)
- break;
- }
- j = protos[j].entry;
- c = m = protocols[j];
- p = NULL;
- while (*m) /* Until end of string */
- {
- if ((*m == '\\') || (*m == ':')) /* Look for last path */
- p = m; /* Delimiter */
- m++;
- }
- m = &junk[0];
- /* It doesn't pay to be too smart here. Dots can appear in dir names */
- while (c != p) /* Copy to last '\' */
- *m++ = *c++;
- while (*c != '.') /* Then to the dot */
- *m++ = *c++;
- strcat (&junk[0], ".ctl"); /* Then add extension */
-
- /*
- * At this point we have the Control File name in (junk), Now let's open
- * the file and put our good stuff in there.
- */
-
- unlink (junk); /* Delete old copies */
- if ((ctlfile = fopen (junk, "a")) == NULL) /* Try to open it */
- {
- status_line ("!Couldn't open CTL file: %s", junk);
- return;
- }
-
- errno = 0;
- fprintf (ctlfile, "Port %d\n", (port_ptr + 1)); /* Port n */
- if (errno)
- goto err;
- if (lock_baud)
- i = max_baud;
- else i = cur_baud;
-
- fprintf (ctlfile, "Modem %x %x %x %x %x\n", /* All modem params */
- (port_ptr + 1), i, handshake_mask, carrier_mask, cur_baud);
- if (errno)
- goto err;
- fprintf (ctlfile, "Baud %u\n", cur_baud); /* Baud Rate */
- if (errno)
- goto err;
- fprintf (ctlfile, "%s %s\n", cmd, name); /* Actual command */
- if (errno)
- {
- err:
- status_line ("!Error writing line to CTL file");
- fclose (ctlfile);
- errno = 0;
- return;
- }
- fclose (ctlfile);
- if (errno)
- {
- status_line ("!Error closing CTL file: %s", junk);
- errno = 0;
- return;
- }
- /* The file is now written. Turn off everything. */
-
- if (!share)
- MDM_DISABLE (); /* Turn off FOSSIL */
-
- if (status_log != NULL)
- fclose (status_log); /* Close status log */
-
- /* We're all set. Build the command and execute it. */
-
- c = protocols[j];
- sprintf (e_input, "%s %s -p%d -b%u %s", c, c, (port_ptr + 1), cur_baud, junk);
- b_spawn (e_input); /* Execute command */
-
- /* Back from external protocol. Turn it all back on. */
-
- if (Cominit (port_ptr) != 0x1954) /* FOSSIL back on */
- {
- cprintf ("\r\nDarn! The FOSSIL seems to have gone away! Exiting\r\n");
- exit (1);
- }
-
- if (status_log != NULL) /* Reopen status log */
- {
- if ((status_log = fopen (log_name, "at")) == NULL)
- {
- cprintf ("\r\nCannot re-open logfile\r\n");
- }
- }
-
- MDM_ENABLE (btypes[baud].rate); /* Reset baud rate */
- XON_ENABLE (); /* and reenable XON/OF */
- }