/*--------------------------------------------------------------------------*/ /* */ /* */ /* ------------ Bit-Bucket Software, Co. */ /* \ 10001101 / Writers and Distributors of */ /* \ 011110 / Freely Available Software. */ /* \ 1011 / */ /* ------ */ /* */ /* (C) Copyright 1987-96, Bit Bucket Software Co. */ /* */ /* 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.260. */ /* */ /* 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 BIT BUCKET */ /* SOFTWARE CO. AT ONE OF 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 BIT BUCKET SOFTWARE, CO. */ /* */ /* */ /* You can contact Bit Bucket Software Co. at any one of the following */ /* addresses: */ /* */ /* Bit Bucket Software Co. FidoNet 1:104/501, 1:343/491 */ /* P.O. Box 460398 AlterNet 7:42/1491 */ /* Aurora, CO 80046 BBS-Net 86:2030/1 */ /* Internet f491.n343.z1.fidonet.org */ /* */ /* Please feel free to contact us at any time to share your comments about */ /* our software and/or licensing policies. */ /* */ /*--------------------------------------------------------------------------*/ /* Include this file before any other includes or defines! */ #include "includes.h" #ifdef Snoop #include "snserver.h" extern HSNOOP hsnoop; #endif void do_extern (char *cmd, int prot, char *name) { int j; struct baud_str *i; char rgchT[100]; char *c, *p, *m; FILE *ctlfile; for (j = 0; j < 100; j++) /* Make sure it's all */ rgchT[j] = '\0'; /* zeroes... */ for (j = 0; j < 5; j++) { if (protos[j].first_char == (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 = &rgchT[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++; (void) strcat (&rgchT[0], ".ctl"); /* Then add extension */ /* * At this point we have the Control File name in (rgchT), Now let's open * the file and put our good stuff in there. */ (void) unlink (rgchT); /* Delete old copies */ if ((ctlfile = fopen (rgchT, append_ascii)) == NULL) /* Try to open it */ { status_line (MSG_TXT (M_NO_CTL_FILE), rgchT); return; } (void) fprintf (ctlfile, "Port %d\n", (port_ptr + 1)); /* Port n */ if (lock_baud && (cur_baud.rate_value >= lock_baud)) i = &max_baud; else i = &pbtypes[baud]; (void) fprintf (ctlfile, "Modem %lx %lx %x %x %x\n", /* All modem params */ (unsigned long)hfComHandle, i->rate_value, handshake_mask, carrier_mask, i->rate_mask); (void) fprintf (ctlfile, "Baud %lu\n", i->rate_value); /* Baud Rate */ (void) fprintf (ctlfile, "%s %s\n", cmd, name); /* Actual command */ (void) fclose (ctlfile); /* The file is now written. Turn off everything. */ if (!share) MDM_DISABLE (); /* Turn off FOSSIL */ #ifdef Snoop if (hsnoop != (HSNOOP) 0L) snoop_close (); #endif /* Snoop */ /* Close status log if need be */ if (status_log != NULL) (void) fclose (status_log); /* Do the same with the cost log */ if (cost_log != NULL) (void) fclose (cost_log); #if defined(OS_2) | defined(_WIN32) ComPause (hcModem); #endif /* We're all set. Build the command and execute it. */ c = protocols[j]; (void) sprintf (e_input, "%s %s -p%lu -b%u %s", c, c, (unsigned long)hfComHandle, i->rate_value, rgchT); b_spawn (e_input); /* Execute command */ /* Back from external protocol. Turn it all back on. */ if (Cominit (port_ptr, buftmo) != 0x1954) /* FOSSIL back on */ { (void) printf ("\n%s\n", MSG_TXT (M_FOSSIL_GONE)); exit (1); } if (status_log != NULL) /* Reopen status log*/ { if ((status_log = share_fopen (log_name, append_ascii, DENY_WRITE)) == NULL) { (void) printf ("\n%s\n", MSG_TXT (M_NO_LOGFILE)); status_log = NULL; } } if (cost_log != NULL) /* Reopen cost log*/ { if ((cost_log = share_fopen (cost_log_name, append_ascii, DENY_WRITE)) == NULL) { (void) printf ("\n%s\n", MSG_TXT (M_NO_COSTFILE)); cost_log = NULL; } } program_baud (); XON_ENABLE (); /* and reenable XON */ }